The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(mobile): screens with pull-to-refresh bounce like every other iOS list
Maurice102e2141ecf6
diff --git a/client/src/mobile/mobile.css b/client/src/mobile/mobile.cssindex 706ba0a00..0b89257e1 100644--- a/client/src/mobile/mobile.css+++ b/client/src/mobile/mobile.css@@ -641,10 +641,10 @@ html:has(.m-shell) {does; the fixed bars stay where they are. The rule above is for the browser,where a pull at the top reloads an installed PWA, which the app cannot do.Not on Android, whose stretch scales the bars too (MainActivity turns it- off), not sideways, and not on a screen with pull-to-refresh, whose pull- WebKit's bounce would race (mobile/usePullToRefresh.ts). */-html[data-native-ios]:not([data-pull-refresh]),-html[data-native-ios]:not([data-pull-refresh]):has(.m-shell) {+ off), and not sideways. A screen with pull-to-refresh bounces too; its pull+ holds only the move down from the top (mobile/usePullToRefresh.ts). */+html[data-native-ios],+html[data-native-ios]:has(.m-shell) {overscroll-behavior-y: auto;}html:has(.m-shell) body {diff --git a/client/src/mobile/usePullToRefresh.test.tsx b/client/src/mobile/usePullToRefresh.test.tsxindex 85dab9e89..1664d113b 100644--- a/client/src/mobile/usePullToRefresh.test.tsx+++ b/client/src/mobile/usePullToRefresh.test.tsx@@ -92,4 +92,23 @@ describe('usePullToRefresh', () => {touch('touchend');expect(onRefresh).not.toHaveBeenCalled();});++ it('holds a clearly downward move at the top from its first pixel, so the bounce does not start under the pull', () => {+ setup();+ touch('touchstart', 100, 100);+ expect(touch('touchmove', 100, 103).defaultPrevented).toBe(true);+ touch('touchend');+ });++ it('leaves the bounce everywhere else: a sideways start, and the page once it is scrolled', () => {+ setup();+ touch('touchstart', 100, 100);+ expect(touch('touchmove', 104, 102).defaultPrevented).toBe(false);+ touch('touchend');+ Object.defineProperty(window, 'scrollY', { value: 300, configurable: true });+ touch('touchstart', 100, 100);+ expect(touch('touchmove', 100, 103).defaultPrevented).toBe(false);+ touch('touchend');+ expect(document.documentElement.hasAttribute('data-pull-refresh')).toBe(false);+ });});diff --git a/client/src/mobile/usePullToRefresh.ts b/client/src/mobile/usePullToRefresh.tsindex a89849865..014b4f1b9 100644--- a/client/src/mobile/usePullToRefresh.ts+++ b/client/src/mobile/usePullToRefresh.ts@@ -24,18 +24,13 @@ function refreshFailed(): void {}* React render per frame; `state` only changes at the edges (armed, refreshing).*//*- * The iOS app lets the page bounce at its ends (mobile.css). A pull is only told- * from a scroll after 8 px, and by then WebKit's own bounce has started and can no- * longer be stopped, so the two would pull at once. While a screen offers- * pull-to-refresh, <html> carries data-pull-refresh and the page does not bounce.+ * The iOS app lets the page bounce at its ends (mobile.css), as every iOS list+ * does. Only the pull down from the very top is this hook's: WebKit starts its+ * own bounce on the first move, long before a pull is told from a scroll at 8 px,+ * so a move that clearly heads down from the top is held from the first pixel.+ * Everywhere else, the bottom of the page included, the bounce stays (TestFlight+ * feedback: the screens with pull-to-refresh used not to bounce at all).*/-let bounceHolds = 0;-function holdBounce(): void {- if (bounceHolds++ === 0) document.documentElement.setAttribute('data-pull-refresh', '');-}-function releaseBounce(): void {- if (--bounceHolds === 0) document.documentElement.removeAttribute('data-pull-refresh');-}export function usePullToRefresh(contentRef: RefObject<HTMLElement | null>,@@ -77,6 +72,8 @@ export function usePullToRefresh(const dx = e.touches[0].clientX - start.x;const dy = e.touches[0].clientY - start.y;if (!pulling) {+ // Clearly downward at the top: WebKit's bounce must not start under the pull.+ if (dy > 0 && dy >= 2 * Math.abs(dx) && scrolled() <= 0 && e.cancelable) e.preventDefault();// Decide once: a sideways or upward start belongs to whatever is under the finger.if (Math.abs(dy) < 8 && Math.abs(dx) < 8) return;if (dy <= 0 || Math.abs(dx) > Math.abs(dy) || scrolled() > 0) {@@ -127,7 +124,6 @@ export function usePullToRefresh(});};- holdBounce();window.addEventListener('touchstart', onStart, { passive: true });// Not passive: once a pull has started, the page must not also scroll or bounce.window.addEventListener('touchmove', onMove, { passive: false });@@ -139,7 +135,6 @@ export function usePullToRefresh(window.removeEventListener('touchend', onEnd);window.removeEventListener('touchcancel', onEnd);place(0, false);- releaseBounce();};}, [contentRef, enabled, scrollerRef]);