
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
scroll-snap
Advanced tools
Snap page when user stops scrolling, with a customizable configuration and a consistent cross browser behaviour
scroll-snap
scroll-snap
is a powerful yet lightweight TypeScript library that provides smooth and customizable page snapping functionality.
Built as a modern implementation of CSS Scroll Snap.
yarn add scroll-snap
import createScrollSnap from 'scroll-snap'
const element = document.getElementById('container')
const { bind, unbind } = createScrollSnap(element, {
snapDestinationY: '100%',
})
Check out the React Hooks demo to see how to integrate scroll-snap in a React application.
Option | Type | Default | Description |
---|---|---|---|
snapDestinationX | string | number | - | Horizontal snap points (e.g., '100%', '500px') |
snapDestinationY | string | number | - | Vertical snap points (e.g., '100%', '500px') |
timeout | number | 100 | Delay before snapping after scroll ends (ms) |
duration | number | 300 | Animation duration (ms) |
threshold | number | 0.2 | Scroll distance threshold (0 to 1) |
snapStop | boolean | false | Prevents skipping intermediate snap positions |
showArrows | boolean | false | Shows navigation arrows when hovering |
enableKeyboard | boolean | true | Enables keyboard arrow keys navigation |
easing | (t: number) => number | linear | Animation easing function |
const scrollSnap = createScrollSnap(element, {
snapDestinationY: '100vh',
duration: 300,
easing: t => t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t
})
const scrollSnap = createScrollSnap(element, {
snapDestinationX: '100%',
showArrows: true,
enableKeyboard: true
})
const scrollSnap = createScrollSnap(element, {
snapDestinationY: '50vh',
threshold: 0.4, // Requires more scroll distance to trigger snap
})
bind()
Enables scroll snapping and attaches event listeners.
unbind()
Disables scroll snapping and removes event listeners.
# Clone the repository
git clone https://github.com/lucafalasco/scroll-snap.git
cd scroll-snap
# Install dependencies
yarn
# Start development server with examples
yarn dev
# Run unit tests
yarn test
# Run integration tests
yarn test:e2e
# Build for production
yarn build
The dev server will start at http://localhost:8080
with hot reloading enabled and a playground environment for testing.
git checkout -b feature/my-feature
git commit -am 'Add my feature'
git push origin feature/my-feature
MIT © Luca Falasco
FAQs
Snap page when user stops scrolling, with a customizable configuration and a consistent cross browser behaviour
The npm package scroll-snap receives a total of 1,316 weekly downloads. As such, scroll-snap popularity was classified as popular.
We found that scroll-snap demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.