Created
November 20, 2017 07:55
-
-
Save bepatrickdavid/a26437c1fb31ffc5b20cf9b83eccfc39 to your computer and use it in GitHub Desktop.
JS: Scroll between section smooth scrolling anchor js
This file contains hidden or 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
/*-------------------------------------------------*/ | |
/* = Scroll between sections | |
/*-------------------------------------------------*/ | |
var $root = $('html, body'); | |
$('a.anchor[href*=#]').on("click",function(event) { | |
event.preventDefault(); | |
var offset = -150; | |
$root.animate({ | |
scrollTop: $( $.attr(this, 'href') ).offset().top + offset | |
}, 500); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment