MarseyWorld/files/assets/js/pwa_pulltorefresh.js

21 lines
662 B
JavaScript
Raw Normal View History

const standalone = navigator.standalone || window.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
window.addEventListener("touchend", () => {
if (window.scrollY < threshold) {
2023-07-14 17:04:12 +00:00
location.reload();
}
});
2023-07-03 00:26:20 +00:00
window.addEventListener("scroll", () => {
img.setAttribute("src", window.scrollY < threshold ? thresholdImg : defaultImg);
});
} else {
2023-07-22 23:49:45 +00:00
const pulltorefresh = document.getElementById("pulltorefresh")
if (pulltorefresh) pulltorefresh.remove();
}