Skip to content

Instantly share code, notes, and snippets.

@scamartist26
Last active August 29, 2015 13:56
Show Gist options
  • Save scamartist26/9272368 to your computer and use it in GitHub Desktop.
Save scamartist26/9272368 to your computer and use it in GitHub Desktop.
smooth page scroll
// requires jQuery and jQuery Easing
var $ = jQuery.noConflict();
function smoothScroll(element, speed, effect, offset) {
$(element).bind('click', function (event) {
$('html, body').stop().animate({
scrollTop: ($($(this).attr('href')).offset().top) - offset
}, speed, effect);
event.preventDefault();
});
}
$(function () {
smoothScroll('a.smooth', 1000, 'easeInOutExpo', 120);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment