sass-site/source/assets/js/components/smooth-scroll.js
2018-12-27 16:31:28 -08:00

17 lines
471 B
JavaScript

$(function() {
$('a[href*=#]:not([href=#])').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
}, 200);
return false;
}
}
});
});