simple-smooth-scroll-by
v0.0.3
Published
ScrollBy with fallback for legacy browsers.
Downloads
20
Readme
Simple smooth scrollBy
Smoothly scrolls by x and y pixels. Demo.
Detects native support of smooth scroll-behavior and fallbacks to tiny reimplementation using requestAnimationFrame
loop.
Installation
npm install simple-smooth-scroll-by
How to use
JavaScript:
import { scrollBy } from 'simple-smooth-scroll-by'
scrollBy(window, 0, 200) // Scroll right by 200px
// or
const container = document.querySelector('#container')
scrollBy(container, 100, 0) // Scroll down by 100px