Created
February 20, 2017 13:10
-
-
Save koentjuh1/eddb767c0ad981b3d79e9d113ed77cc6 to your computer and use it in GitHub Desktop.
onepage scroll smooth with 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
$('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