Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- $("a[href^=#]").scrollToAnchor(); // scroll to any link at default speed
- $("a.slowerScroll").scrollToAnchor({ speed: 2000 }); // scroll to links with class slowerScroll at half speed
- });
- jQuery.fn.scrollToAnchor = function(settings) {
- settings = jQuery.extend({ speed : 1000 }, settings);
- return this.each(function() {
- var self = $(this);
- self.click(function(e) {
- e.preventDefault();
- var href = self.attr("href");
- var target = $(href).offset().top;
- $("html:not(:animated), body:not(:animated)").animate({ scrollTop: target }, settings.speed, function() {
- window.location.hash = href;
- });
- return false;
- });
- });
- };
Add Comment
Please, Sign In to add comment