Created
October 3, 2015 21:54
-
-
Save cesarkohl/9b57833f6533c156c67c to your computer and use it in GitHub Desktop.
jQuery - Anchor section with fade
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
| /** | |
| * Anchor with fade | |
| * Example: <a href="#example-1"/> <div id="example-2"/> | |
| */ | |
| $('a.scroll-smooth').on('click',function (e) { | |
| e.preventDefault(); | |
| var target = this.hash; | |
| var $target = $(target); | |
| $('html, body').stop().animate({ | |
| 'scrollTop': $target.offset().top | |
| }, 'slow', 'swing', function () { | |
| window.location.hash = target; | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment