$('a[href^="#"]').click(function(){
var target = $(this).attr('href');
$('html, body').animate({
scrollTop: $(target).offset().top
}, 500);
});
$('a[href*="#"]').click(function(e) {
const $target = $(this.hash);
const topOffset = 100;
if ($target.length) {
e.preventDefault();
$("html, body")
.stop()
.animate(
{
scrollTop: $target.offset().top - topOffset
},
900,
"swing",
function() {
history.pushState(
{},
document.title,
window.location.pathname + target
);
return false;
// window.location.hash = target;
}
);
}
});