Created
December 8, 2016 09:45
-
-
Save RolandVels/439a4210596d024ba2a230058cdf0fe6 to your computer and use it in GitHub Desktop.
smoothScroll
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
smoothScroll(1000); | |
function smoothScroll (duration) { | |
$('a[href^="#"]').on('click', function(event) { | |
var target = $( $(this).attr('href') ); | |
if( target.length ) { | |
event.preventDefault(); | |
$('html,body').animate({ | |
scrollTop: target.offset().top | |
}, duration); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment