Skip to content

Instantly share code, notes, and snippets.

@travismillerweb
Created February 13, 2014 17:44
Show Gist options
  • Save travismillerweb/8980130 to your computer and use it in GitHub Desktop.
Save travismillerweb/8980130 to your computer and use it in GitHub Desktop.
JS - Section Scrolling Ease
sectionScrolling: function () {
$('.specialized-practice-menu li a[href*=#]:not([href=#])').click(function(e) {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top -50
}, 500);
return false;
}
}
e.preventDefault();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment