Animated scrollTo
This is a simple function for animating scroll.
- No dependency on extra libraries.
- If user scrolls while animation is running, scroll animation would be immediately canceled.
- Use as a single script or through bower.
Example usage
button.addEventListener('click', function () {
animatedScrollTo(
document.body,
0,
10000,
function() {
console.log('done!')
}
);
});
This will scroll to top of the page and the animation will run for 10 seconds (10000ms).
Available on Bower
bower install animated-scrollto
Just import with <script>
and global function animatedScrollTo
will be available for you.
Available with Browserify
npm install animated-scrollto
In your browserify powered js:
var animatedScrollTo = require('animated-scrollto')
License
MIT