Created
April 11, 2017 04:20
-
-
Save andremahendra/038eb1abcf31276d4c640d7a2748c133 to your computer and use it in GitHub Desktop.
on click element go to target div
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
// reference: http://stackoverflow.com/questions/27554831/javascript-scroll-to-element-with-animation-onclick | |
$('.go--to').click(function () { | |
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { | |
var target = $(this.hash); | |
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); | |
if (target.length) { | |
$('html,body').animate({ | |
scrollTop: target.offset().top - 90 | |
}, 1000); | |
return false; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment