Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(function($) {
$.fn.smoothScroll = function() {
return this.on('click', function() {
var hash = $(this).attr('href');
var dest = $(hash).offset();
$('html:not(:animated),body:not(:animated)').animate({scrollTop: dest.top, scrollLeft: dest.left}, 500, function() {
window.location.hash = hash;
});
return false;
});
};
})(jQuery);
$(function() {
$('a[rel=scroll]').smoothScroll();
});
@mxlje

This comment has been minimized.

Copy link

@mxlje mxlje commented Dec 10, 2012

This is great, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment