Last active
March 18, 2025 07:34
-
-
Save Krutsch/2265cc727cb5ca55779f1a75a5573ee3 to your computer and use it in GitHub Desktop.
iOS PWA Pull to Refresh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const standaloneIOS = | |
| (navigator.standalone || | |
| window.matchMedia("(display-mode: standalone)").matches) && | |
| CSS.supports("-webkit-touch-callout", "none"); | |
| if (standaloneIOS) { | |
| const classes = ["pointer-events-none", "opacity-20", "overflow-hidden"]; // optional setting classes | |
| let loading = false; | |
| document.addEventListener("scroll", (event) => { | |
| if (window.scrollY < -150 && !loading) { | |
| loading = true; | |
| document.body.classList.add(...classes); | |
| // TODO: your logic | |
| document.body.classList.remove(...classes); | |
| loading = false; | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment