Created
July 12, 2013 11:03
-
-
Save hlashbrooke/5983618 to your computer and use it in GitHub Desktop.
Simple animated scroll for jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function scrollToElement( target ) { | |
var topoffset = 30; | |
var speed = 800; | |
var destination = jQuery( target ).offset().top - topoffset; | |
jQuery( 'html:not(:animated),body:not(:animated)' ).animate( { scrollTop: destination}, speed, function() { | |
window.location.hash = target; | |
}); | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment