Fix issues caused by missing gttBtn when enableGoToTop is false

This commit is contained in:
Yoni 2021-08-21 14:00:10 +03:00
parent 01f9e43e59
commit 9c63e8cb3e
1 changed files with 41 additions and 33 deletions

View File

@ -243,6 +243,7 @@
// ========================= go to top =========================
{{ if $.Param "enableGoToTop" }}
var gttBtn = document.getElementById("gtt");
gttBtn.style.display = "none";
gttBtn.addEventListener('click', function () {
@ -270,6 +271,7 @@
gttBtn.style.display = "none";
}
}
{{ end }}
// ============================================================
@ -347,15 +349,19 @@
window.onscroll = function () {
{{ if $.Param "enableGoToTop" }}
scrollFunction();
{{ end }}
var st = window.pageYOffset || document.documentElement.scrollTop;
if (st > lastScrollTop) { // scroll down
{{ if $.Param "enableGoToTop" }}
if (st < 250) {
gttBtn.style.display = "none";
} else {
gttBtn.style.display = "block";
}
{{ end }}
if (st < 45) {
return null;
@ -429,9 +435,11 @@
}
}
} else { // scroll up
{{ if $.Param "enableGoToTop" }}
if (st < 250) {
gttBtn.style.display = "none";
}
{{ end }}
if (navbar.classList.contains('scrolling')) {
if (navbar.classList.contains('navbar--hide')) {