Skip to content

Instantly share code, notes, and snippets.

@mikedugan
Created November 11, 2013 22:48
Show Gist options
  • Save mikedugan/7421985 to your computer and use it in GitHub Desktop.
Save mikedugan/7421985 to your computer and use it in GitHub Desktop.
scrolls to a point on a page given anchor & offset
//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