Smooth Scroll With Configurable Speed, Easing And Offset - animateScroll.js
File Size: | 10.4 KB |
---|---|
Views Total: | 2565 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |
animateScroll.js is a small and easy-to-use smooth scroll plugin which animates the page scrolling to a specific element with configurable offset, easing effect, and animation speed.
How to use it:
1. Insert the minified version of the animateScroll.js plugin after jQuery library.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"> </script> <script src="animatescroll.js"></script>
2. Smoothly scroll the page to a specific element within the document.
<p id="top"></p>
$(function(){ $('#top').animatescroll(); });
3. Customize the animation speed in milliseconds. Default: 800.
$(function(){ $('#top').animatescroll({ scrollSpeed: 2000 }); });
4. Customize the easing effect. All possible easing functions:
- swing
- easeInQuad
- easeOutQuad
- easeInOutQuad
- easeInCubic
- easeOutCubic
- easeInOutCubic
- easeInQuart
- easeOutQuart
- easeInOutQuart
- easeInQuint
- easeOutQuint
- easeInOutQuint
- easeInSine
- easeOutSine
- easeInOutSine
- easeInExpo
- easeOutExpo
- easeInOutExpo
- easeInCirc
- easeOutCirc
- easeInOutCirc
- easeInElastic
- easeOutElastic
- easeInOutElastic
- easeInBack
- easeOutBack
- easeInOutBack
- easeInBounce
- easeOutBounce
- easeInOutBounce
$(function(){ $('#top').animatescroll({ easing:"swing" }); });
5. Customize the offset in pixels. Default: 0.
$(function(){ $('#top').animatescroll({ padding: 150 }); });
6. Smoothly scroll a specific container instead of the whole body.
$(function(){ $('#top').animatescroll({ element:".yourContainer" }); });
7. Available callback functions which will be triggered when the smooth scroll starts and ends.
$(function(){ $('#top').animatescroll({ onScrollStart: function(){ // do something }, onScrollEnd: function(){ // do something } }); });
This awesome jQuery plugin is developed by rampatra. For more Advanced Usages, please check the demo page or visit the official website.