mirror of
https://github.com/Juicysteak117/pghrt.git
synced 2025-12-21 15:35:25 +00:00
one last javascript fix
This commit is contained in:
@@ -130,7 +130,8 @@ function saveScroll() {
|
|||||||
|
|
||||||
// it returns to scroll positions stored in the array "scrollPos"
|
// it returns to scroll positions stored in the array "scrollPos"
|
||||||
function returnScroll() {
|
function returnScroll() {
|
||||||
document.getElementById("return").addEventListener("click", () => {
|
const ret = document.getElementById("return");
|
||||||
|
ret.addEventListener("click", () => {
|
||||||
|
|
||||||
const scrollArray = JSON.parse(sessionStorage.getItem("scrollPos") ?? "[]").map(num => Number(num));
|
const scrollArray = JSON.parse(sessionStorage.getItem("scrollPos") ?? "[]").map(num => Number(num));
|
||||||
// check if saved, otherwise goto top and remove back arrow
|
// check if saved, otherwise goto top and remove back arrow
|
||||||
@@ -140,13 +141,13 @@ function returnScroll() {
|
|||||||
window.scroll(0, pos);
|
window.scroll(0, pos);
|
||||||
}
|
}
|
||||||
else if (scrollArray.length === 1) {
|
else if (scrollArray.length === 1) {
|
||||||
this.classList.remove("show");
|
ret.classList.remove("show");
|
||||||
let pos = scrollArray.shift();
|
let pos = scrollArray.shift();
|
||||||
sessionStorage.setItem("scrollPos", JSON.stringify(scrollArray));
|
sessionStorage.setItem("scrollPos", JSON.stringify(scrollArray));
|
||||||
// scroll to top
|
// scroll to top
|
||||||
window.scroll(0, pos);
|
window.scroll(0, pos);
|
||||||
} else {
|
} else {
|
||||||
this.classList.remove("show");
|
ret.classList.remove("show");
|
||||||
// scroll to top
|
// scroll to top
|
||||||
window.scroll(0, 0);
|
window.scroll(0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user