mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 02:34:21 +00:00
fix(mobile): keep the page clear of a Duo's status capsule and leave a scrolled column's pull to it
TestFlight feedback from an iPhone Duo: - Folded, the status capsule stands in the right inset and ran over the hero card's actions; the page now keeps clear of the side insets as iOS asks (.m-page), and a floating bar keeps a little air next to an inset. - Unfolded, the top bar ignored the trailing inset and the capsule sat on the avatar; on a wide window the bars now end before it, by their box, so a bar that centres itself still does. - Dragging the dashboard's second column back up refreshed the page: a pull that starts inside a box scrolled on its own now belongs to that box.
This commit is contained in:
@@ -13,6 +13,25 @@ export type PullState = { distance: number; refreshing: boolean; armed: boolean
|
||||
/** The screen's own refresh reports its failures (a toast, its error state); the pull only lets go. */
|
||||
function refreshFailed(): void {}
|
||||
|
||||
/**
|
||||
* Whether the touch starts inside a box that scrolls on its own and is not at
|
||||
* its top, such as the second column of the dashboard on an unfolded Duo or an
|
||||
* iPad. That pull scrolls the box back up; it is no refresh of the page
|
||||
* (TestFlight feedback: dragging the right column back up refreshed instead).
|
||||
*/
|
||||
export function insideScrolledBox(target: EventTarget | null, page: Element | null): boolean {
|
||||
for (
|
||||
let el = target instanceof Element ? target : null;
|
||||
el && el !== page && el !== document.body;
|
||||
el = el.parentElement
|
||||
) {
|
||||
if (el.scrollTop <= 0 || el.scrollHeight <= el.clientHeight) continue;
|
||||
const overflow = getComputedStyle(el).overflowY;
|
||||
if (overflow === 'auto' || overflow === 'scroll') return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pull-to-refresh on a page whose scroller is the window, as the mobile
|
||||
* dashboard is. A downward drag that starts at the very top moves `contentRef`
|
||||
@@ -63,6 +82,7 @@ export function usePullToRefresh(
|
||||
|
||||
const onStart = (e: TouchEvent) => {
|
||||
if (busy || e.touches.length !== 1 || scrolled() > 0 || hasOpenOverlay()) return;
|
||||
if (insideScrolledBox(e.target, scrollerRef?.current ?? null)) return;
|
||||
start = { x: e.touches[0].clientX, y: e.touches[0].clientY };
|
||||
pulling = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user