Smooth Scroll to target ID or name
// Scroll to name
/* Smooth scroll javascript to ID */
jQuery(function($) {
$('a[href*="#"]:not([href="#"])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
var headerOffset = $('header.smaller').outerHeight();
console.log(headerOffset);
var targetPos = target.offset().top;
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: ( targetPos - headerOffset - 150)
}, 1000);
return false;
}
}
});
});