Skip to content

Instantly share code, notes, and snippets.

@koentjuh1
Created February 20, 2017 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koentjuh1/eddb767c0ad981b3d79e9d113ed77cc6 to your computer and use it in GitHub Desktop.
Save koentjuh1/eddb767c0ad981b3d79e9d113ed77cc6 to your computer and use it in GitHub Desktop.
onepage scroll smooth with offset
$('a[href*="#"]:not([href="#"])').on('click',function(e) {
e.preventDefault();
var offset = 94;
var target = this.hash;
if ($(this).data('offset') != undefined) offset = $(this).data('offset');
$('html, body').stop().animate({
'scrollTop': $(target).offset().top - offset
}, 800, 'swing', function() {
// window.location.hash = target;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment