Animated scrolling to an element or position
npm install @degjs/scroll-toScrollTo is a module that will scroll to a specified element or position on a page with animated movement. It takes advantage of the native window.requestAnimationFrame() method to ensure smooth animation.
If you're already using NPM for your project, you can install scrollTo with the following command:
```
$ npm install @degjs/scroll-to`Usage
js
import scrollTo from "@degjs/scroll-to";
/ Scroll to an element with a 1-second, eased-in animation /
let destinationElement = document.querySelector('.some-element');
scrollTo({
element: destinationElement,
duration: 1000,
easing: 'easeIn'
});
`
#### options.element
Type:
Element
The element to scroll to. This option or the position option is required.#### options.position
Type:
Number
The vertical position (in pixels) on the page to scroll to. This option or the element option is required.#### options.duration
Type:
Number Default: 500
The duration (in milliseconds) of the scroll animation. This option is optional.#### options.easing
Type:
String Default: easeOut` To support legacy browsers, you'll need to include polyfills for the above APIs.