Created
January 15, 2012 01:13
-
-
Save andredublin/1613741 to your computer and use it in GitHub Desktop.
Sometimes localscroll doesn't work for me, so I made this function to do simply vertical navigation
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
$navLinks.click(function(event) { | |
var pos1, pos2, hash, start, end, total, time, | |
$this = $(this), | |
offset = $($this.attr('href')).offset().top, | |
pos1 = $this.offset().top, | |
hash = event.currentTarget.hash.toString(), | |
pos2 = $(hash.toString()).offset().top, | |
$target = $('html, body'); | |
start = parseInt(pos1); | |
end = parseInt(pos2); | |
total = start - end; | |
time = Math.abs(total); | |
$target.animate({scrollTop:offset}, time, 'easeInOutQuint'); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment