MarseyWorld/files/assets/js/pwa_pulltorefresh.js

21 lines
627 B
JavaScript
Raw Normal View History

2023-09-29 00:37:03 +00:00
const standalone = navigator.standalone || matchMedia("(display-mode: standalone)").matches;
if (standalone) {
const img = document.getElementById("pulltorefresh-img");
const defaultImg = "/e/marseythinkorino.webp";
const thresholdImg = "/e/marseythumbsup.webp";
const threshold = -100;
2023-07-03 00:26:20 +00:00
2023-08-03 13:50:33 +00:00
addEventListener("touchend", () => {
2023-09-29 00:37:03 +00:00
if (scrollY < threshold) {
2023-07-14 17:04:12 +00:00
location.reload();
}
});
2023-07-03 00:26:20 +00:00
2023-08-03 13:50:33 +00:00
addEventListener("scroll", () => {
2023-09-29 00:37:03 +00:00
img.setAttribute("src", scrollY < threshold ? thresholdImg : defaultImg);
});
} else {
2023-07-22 23:49:45 +00:00
const pulltorefresh = document.getElementById("pulltorefresh")
if (pulltorefresh) pulltorefresh.remove();
}