docs(nav): restoreNavPosition's doc back on restoreNavPosition
This commit is contained in:
@@ -358,14 +358,9 @@ export function navPosition(): NavPosition | null {
|
|||||||
const RESTORE_MS = 2000;
|
const RESTORE_MS = 2000;
|
||||||
const RESTORE_POLL_MS = 50;
|
const RESTORE_POLL_MS = 50;
|
||||||
|
|
||||||
/** Focus the item at `pos` once its list is on screen again. A NAMED list (a rail) is found by its
|
/** The item in `list` to hand the focus back to: the saved place while it still holds the saved
|
||||||
* name: a rail that appeared above it in the meantime — "Continue watching", filled by the very title
|
* name, else the nearest item of that name (names repeat — a log console's identical request
|
||||||
* watched in between, after the page's cache expired — shifts every place after it, and matching by
|
* lines), else the saved place. */
|
||||||
* place landed the focus in the wrong rail (deep-review E11 round 2). An unnamed list only by its
|
|
||||||
* place, and only once the page has exactly as many lists as when it was left: with more or fewer,
|
|
||||||
* list N may be another list, and <body> is the honest outcome. Gives up when the time is up, and at
|
|
||||||
* once when focus is already somewhere (the reader moved on, a dialog took it). The item is focused
|
|
||||||
* where the scroll restore put it, never scrolled to. Returns a cancel. */
|
|
||||||
function restoreTarget(list: NavList, pos: NavPosition): HTMLElement | null {
|
function restoreTarget(list: NavList, pos: NavPosition): HTMLElement | null {
|
||||||
const at = itemAt(list, pos.index);
|
const at = itemAt(list, pos.index);
|
||||||
if (!pos.name || (at && itemName(at) === pos.name)) return at;
|
if (!pos.name || (at && itemName(at) === pos.name)) return at;
|
||||||
@@ -376,6 +371,14 @@ function restoreTarget(list: NavList, pos: NavPosition): HTMLElement | null {
|
|||||||
return named[0] ?? at;
|
return named[0] ?? at;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Focus the item at `pos` once its list is on screen again. A NAMED list (a rail) is found by its
|
||||||
|
* name: a rail that appeared above it in the meantime — "Continue watching", filled by the very title
|
||||||
|
* watched in between, after the page's cache expired — shifts every place after it, and matching by
|
||||||
|
* place landed the focus in the wrong rail (deep-review E11 round 2). An unnamed list only by its
|
||||||
|
* place, and only once the page has exactly as many lists as when it was left: with more or fewer,
|
||||||
|
* list N may be another list, and <body> is the honest outcome. Gives up when the time is up, and at
|
||||||
|
* once when focus is already somewhere (the reader moved on, a dialog took it). The item is focused
|
||||||
|
* where the scroll restore put it, never scrolled to. Returns a cancel. */
|
||||||
export function restoreNavPosition(pos: NavPosition): () => void {
|
export function restoreNavPosition(pos: NavPosition): () => void {
|
||||||
const deadline = Date.now() + RESTORE_MS;
|
const deadline = Date.now() + RESTORE_MS;
|
||||||
let timer: ReturnType<typeof setTimeout> | undefined;
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user