@make-use-of/scroll-horiz
v0.1.0
Published
Lightweight smooth horizontal scrolling. Respects prefers-reduced-motion.
Downloads
6
Maintainers
Readme
@make-use-of/scroll-horiz
Lightweight, dependency-free smooth horizontal scrolling for any element. Respects prefers-reduced-motion.
Install
npm install @make-use-of/scroll-horizQuick start
import scrollHoriz from '@make-use-of/scroll-horiz';
// Call once on the client (e.g., after mount)
scrollHoriz();
// Then use the standard API
document.querySelector('.carousel').scrollBy(300, 0);API
- scrollHoriz(): void — initializes the enhancer.
- After init,
element.scrollBy(x, y)performs smooth horizontal scrolling when motion is allowed.
Notes:
- Honors
prefers-reduced-motion: reduce(instant scroll, no animation). - Works even if the browser supports CSS
scroll-behavior. - Use in browser-only lifecycles (
useEffect,onMounted, etc.).
