Simple scroll utility for centering elements and smooth animations. v4.0.2 is the latest stable release (May 2019). Provides a Scroll class to control scroll on any element with customizable easing, duration, and onScroll callbacks. Supports both absolute scrollTo and relative scrollBy with sub-methods for elements, sizes, and scroll sizes. Ships TypeScript types. Differentiators: handles multiple simultaneous animations, detects programmatic vs user scroll, reacts to element position changes, high performance, and works in both Node and browser environments. Designed for precise control over scroll behavior in web applications, with a clean API that avoids common pitfalls of native scroll.
npm install scroll-utilityNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic scroll operations: scrolling to position, centering an element, relative scrolling, and creating a manager for a specific container.
Update code to use the new API: scrollManager.scrollTo.element('#element') instead of old scrollManager.scrollToElement('#element').Use the new unified Scroll class. Import { Scroll } from 'scroll-utility' and use its scrollTo/scrollBy methods.Always provide the container element explicitly: new Scroll(document.querySelector('#scrollable')).Check the callback parameter: onScroll: (position, isProgrammatic) => { if (isProgrammatic) return; /* user scroll */ }Monitor for future releases that might fix glitchy behavior. Consider using a single animation at a time or implementing a queue.
Use import { Scroll } from 'scroll-utility' instead of import Scroll from 'scroll-utility'.Use ScrollUtility.Scroll instead of Scroll when loaded via script tag.
Ensure the container element is scrollable (has overflow: auto/scroll and sufficient content). Create manager with explicit container: new Scroll(document.getElementById('container')).Update to a version that includes full type definitions. Ensure you are using v4.0.0+ which has complete types.
No dependency data recorded yet.