slidebox-js
Version:
A jQuery plugin for easy creation of responsive lightbox-style media galleries and carousels.
31 lines (21 loc) • 590 B
JavaScript
// jshint ignore: start
function scrollToTarget(target) {
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - 42
}, 750);
return false;
}
}
function smoothScrolling() {
$('a[href*="#"]:not([href="#"])').on('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) + ']');
scrollToTarget(target);
}
});
}
$(function () {
smoothScrolling();
});