Fix smooth scrolling - prevent one target bind
This commit is contained in:
parent
025956ef46
commit
fe30218240
@ -2,13 +2,18 @@
|
|||||||
"use strict"; // Start of use strict
|
"use strict"; // Start of use strict
|
||||||
|
|
||||||
// Smooth scrolling using jQuery easing
|
// Smooth scrolling using jQuery easing
|
||||||
|
let lastLength = null;
|
||||||
$('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function () {
|
$('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function () {
|
||||||
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
|
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
|
||||||
var target = $(this.hash);
|
var target = $(this.hash);
|
||||||
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
|
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
|
||||||
if (target.length) {
|
if (target.length && lastLength !== target.length) {
|
||||||
|
lastLength = target.length;
|
||||||
$('html, body').animate({
|
$('html, body').animate({
|
||||||
scrollTop: (target.offset().top - 54)
|
scrollTop: (target.offset().top - 54),
|
||||||
|
complete: function () {
|
||||||
|
lastLength = null;
|
||||||
|
}
|
||||||
}, 1000, "easeInOutExpo");
|
}, 1000, "easeInOutExpo");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user