sass-site/source/assets/js/components/smooth-scroll.js

17 lines
480 B
JavaScript
Raw Normal View History

2013-10-12 21:58:56 +02:00
$(function() {
$('.anchors a[href*=#]:not([href=#])').click(function() {
2013-10-12 21:58:56 +02:00
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);
2013-10-12 21:58:56 +02:00
return false;
}
}
});
});