The reader rebuilds its scroller when an item opens on a phone (#450)

Every scroll_stuck report since the added fields was a short drag over
text in a reader whose content had just been swapped, with nothing over
it, nothing inert and the touch left alone by the page: iOS kept the drag
and did not scroll. That fits WebKit keeping an overflow box's scroller
sized for what was there before. Overflow is taken away for two frames
after each open, and after a stuck drag is caught, so the scroller is
built again; the report now says how long since the last one, which tells
whether this freed it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RqkrVCCH8YcP2Y3i8VNYWA
This commit is contained in:
2026-11-27 17:26:41 -05:00
parent 1f4ad44da8
commit 9e3ffd80c1
4 changed files with 26 additions and 1 deletions

View File

@@ -243,7 +243,20 @@ document.addEventListener('touchend', ev => {
if(stuckDrag(dy, dx, g.top, d.scrollTop, room)) stuck(d, t, g, dy, room, ms);
}, 300);
});
/// Makes iOS build the reader's scroller again (#450): every stuck drag was on a reader whose
/// content had been swapped, with nothing over it and the touch left alone, which is WebKit keeping
/// a scroller sized for what was there before. Two frames without overflow, so the hidden state is
/// committed and not merged away with the change back.
function rearm(d: HTMLElement){
d.style.overflowY = 'hidden';
requestAnimationFrame(() => requestAnimationFrame(() => { d.style.overflowY = ''; }));
}
let stuckAt = 0;
function stuck(d: HTMLElement, t: Touch, g: NonNullable<typeof drag>, dy: number, room: number, ms: number){
rearm(d);
// A second report soon after the first says rearm did not free it.
const again = stuckAt ? Math.round((Date.now() - stuckAt) / 1000) + 's ago' : 'never';
stuckAt = Date.now();
const inert = ([...document.body.children] as HTMLElement[]).filter(el => el.inert).map(named).join(' ');
report('scroll_stuck', {feed: S.feed, state: [
`top ${g.top} of ${room}`, `drag ${Math.round(dy)}px`, `started on ${g.on}`,
@@ -253,5 +266,5 @@ function stuck(d: HTMLElement, t: Touch, g: NonNullable<typeof drag>, dy: number
`overflow ${getComputedStyle(d).overflowY}`, `reading ${document.body.classList.contains('reading')}`,
`shown ${Math.round((Date.now() - shownAt) / 1000)}s ago`, `${S.entries.length} loaded`,
`from x ${Math.round(g.x)}`, `${g.moves} moves seen in ${ms}ms`, `touch ${g.cancelled ? 'cancelled' : 'left alone'}`,
`slid ${slidAt ? Math.round((Date.now() - slidAt) / 1000) + 's ago' : 'never'}`].join(', ')});
`slid ${slidAt ? Math.round((Date.now() - slidAt) / 1000) + 's ago' : 'never'}`, `last stuck ${again}`].join(', ')});
}