### Live demo
- Using requestAnimationFrame
- 3.2k minified and gzipped
- Runs the animation at 60 FPS
- Available as a script or UMD
- Only one dependency to have requestAnimationFrame cross-browser
- If user scrolls while animation is running, scroll animation would be immediately canceled
Install
npm install scrollto-with-animation --save
Usage
Available as a UMD
var scrollToWithAnimation = require('scrollto-with-animation')
import scrollToWithAnimation from 'scrollto-with-animation'
or as a script
<script src="https://unpkg.com/scrollto-with-animation/dist/scrollto-with-animation.min.js"></script>
Example
scrollToWithAnimation(
document.documentElement,
'scrollTop',
0,
10000,
'easeInOutCirc',
function () {
console.log('done!')
}
);
This will scroll to top of the page and the animation will run for 10 seconds (10000ms).
## Options
Posible easings equations
linearTween
easeInQuad
easeOutQuad
easeInOutQuad
easeInCubic
easeOutCubic
easeInOutCubic
easeInQuart
easeOutQuart
easeInOutQuart
easeInQuint
easeOutQuint
easeInOutQuint
easeInSine
easeOutSine
easeInOutSine
easeInExpo
easeOutExpo
easeInOutExpo
easeInCirc
easeOutCirc
easeInOutCirc
Feel free to add more ease functions to easings.js open a Pull request!
License
MIT