v0.5.1 fixed mobile PWA refesh
This commit is contained in:
@@ -30,6 +30,11 @@
|
||||
|
||||
html, body, #root { height: 100%; min-width: 320px; font-family: var(--font); color: var(--text-primary); background: var(--background); }
|
||||
|
||||
/* Disable pull-to-refresh in PWA standalone mode — prevents viewport shift bug */
|
||||
html {
|
||||
overscroll-behavior-y: none;
|
||||
}
|
||||
|
||||
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
|
||||
input, textarea { font-family: var(--font); }
|
||||
a { color: inherit; text-decoration: none; }
|
||||
|
||||
@@ -17,6 +17,28 @@ if ('serviceWorker' in navigator) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Disable pull-to-refresh in PWA standalone mode to prevent viewport shift bug.
|
||||
// The CSS overscroll-behavior-y:none handles most browsers; this catches the rest.
|
||||
(function () {
|
||||
const isStandalone = window.matchMedia('(display-mode: standalone)').matches
|
||||
|| window.navigator.standalone === true;
|
||||
if (!isStandalone) return;
|
||||
|
||||
let startY = 0;
|
||||
document.addEventListener('touchstart', e => {
|
||||
startY = e.touches[0].clientY;
|
||||
}, { passive: true });
|
||||
|
||||
document.addEventListener('touchmove', e => {
|
||||
// Only block downward pull at the very top of the document
|
||||
const dy = e.touches[0].clientY - startY;
|
||||
if (dy > 0 && (document.documentElement.scrollTop === 0 || document.body.scrollTop === 0)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}, { passive: false });
|
||||
})();
|
||||
|
||||
// Clear badge count when user focuses the app
|
||||
window.addEventListener('focus', () => {
|
||||
if (navigator.clearAppBadge) navigator.clearAppBadge().catch(() => {});
|
||||
|
||||
Reference in New Issue
Block a user