Skip to content

Instantly share code, notes, and snippets.

@aziz aziz/soft-scroll.js
Created Jun 10, 2011

Embed
What would you like to do?
Soft-scroll to an anchor with jQuery
$('a[href^="#"][data-animate]').live('click', function() {
var hash = $(this).attr('href');
var offset = $(hash).offset();
if (offset) {
$('html, body').animate({ scrollTop: offset.top }, 'slow');
location.hash = hash;
return false;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.