fix: re-land explicit navigation when the reading stage changes mid-journey
This commit is contained in:
@@ -113,6 +113,13 @@ const browserRuntime = (): NavigationRuntime => ({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
focusHeading: (target) => {
|
focusHeading: (target) => {
|
||||||
|
// The live reading stage can start or stop while a long journey is still
|
||||||
|
// in flight (the scene boots lazily and steps down on slow GPUs), which
|
||||||
|
// shifts layout under the scroll. Re-land once, instantly, before focus.
|
||||||
|
const margin = parseFloat(getComputedStyle(target).scrollMarginTop) || 0;
|
||||||
|
const delta = target.getBoundingClientRect().top - margin;
|
||||||
|
if (Math.abs(delta) > 2)
|
||||||
|
window.scrollTo({ top: window.scrollY + delta, behavior: "instant" });
|
||||||
target
|
target
|
||||||
.querySelector<HTMLElement>('h1[tabindex="-1"], h2[tabindex="-1"]')
|
.querySelector<HTMLElement>('h1[tabindex="-1"], h2[tabindex="-1"]')
|
||||||
?.focus({ preventScroll: true });
|
?.focus({ preventScroll: true });
|
||||||
|
|||||||
Reference in New Issue
Block a user