Created
November 11, 2013 22:48
-
-
Save mikedugan/7421985 to your computer and use it in GitHub Desktop.
scrolls to a point on a page given anchor & offset
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
//scrolls to a given point with offset n from point (750) | |
scrollTo: function() { | |
$('#main-nav').find('li > a').on("click", function(e){ | |
$('#main-nav').find('li').removeClass('active'); | |
$(this).parent().addClass('active'); | |
var id = $(this).attr("href"); | |
$('html, body').animate({ | |
scrollTop: $(id).offset().top | |
}, 750); | |
e.preventDefault(); | |
}); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment