scrollTo
Simple pure javascript smooth scrolling to element
This script exports two modules, scrollToTop
and scrollTo
, which can then be imported using the JS import statement currently available in Traceur, Babel, or Rollup.
Install
npm install scrollyo --save
With a "y".
Usage
First import the modules you need:
// Both;
// Just one;
You can now use scrollToTop
and/or scrollTo
:
-
scrollToTop
scrolls to the top of the page. Takes one argument for the timeout in miliseconds.; -
scrollTo
scrolls to any element in the DOM unless the element is already at thescrollTo
position. The function takes two arguments: the element and a timeout in miliseconds (both mandatory).const myElement = document;;