Fix smooth scrolling - prevent one target bind

This commit is contained in:
František Musil 2023-10-01 20:10:25 +02:00
parent 025956ef46
commit fe30218240

View File

@ -2,13 +2,18 @@
"use strict"; // Start of use strict
// Smooth scrolling using jQuery easing
let lastLength = null;
$('a.js-scroll-trigger[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) {
if (target.length && lastLength !== target.length) {
lastLength = target.length;
$('html, body').animate({
scrollTop: (target.offset().top - 54)
scrollTop: (target.offset().top - 54),
complete: function () {
lastLength = null;
}
}, 1000, "easeInOutExpo");
return false;
}