Smooth Scroll jQuery Plugin - Automatically make same-page links scroll smoothly

Smooth Scroll jQuery Plugin automatically makes same-page links scroll smoothly.

 

$.fn.smoothScroll:

  • Allows for easy implementation of smooth scrolling for same-page links.
  • Works like this: $('a').smoothScroll();
  • Specify a containing element if you want: $('#container a').smoothScroll();
  • Exclude links if they are within a containing element: $('#container a').smoothScroll({excludeWithin: ['.container2']});
  • Exclude links if they match certain conditions: $('a').smoothScroll({exclude: ['.rough','#chunky']});
  • Adjust where the scrolling stops: $('.backtotop').smoothScroll({offset: -100});
  • Add a callback function that is triggered before the scroll starts: `$('a').smoothScroll({beforeScroll: function() { alert('ready to go!'); }});
  • Add a callback function that is triggered after the scroll is complete: $('a').smoothScroll({afterScroll: function() { alert('we made it!'); }});
  • Add back button support by including a history management plugin.

 

w10schools
2014-05-17 03:09:22
Comments
Leave a Comment

Please login to continue.