feat: light a chapter when its heading crosses 60% of the viewport

This commit is contained in:
2026-10-11 01:11:09 +03:00
parent 7fa1c08ce8
commit d6045ad2c1
3 changed files with 13 additions and 6 deletions

View File

@@ -32,10 +32,17 @@ export interface ActivationLineInput {
visualViewportHeight: number;
}
/**
* A chapter becomes current when its heading's top crosses this fraction of
* the visual viewport, measured from the top. At 60% the chapter lights up as
* its heading settles into the reading zone, not after it has been read.
*/
export const ACTIVATION_LINE_VH = 0.6;
export const activationLineDocumentY = (input: ActivationLineInput): number =>
input.scrollY +
input.visualViewportOffsetTop +
input.visualViewportHeight * 0.35;
input.visualViewportHeight * ACTIVATION_LINE_VH;
export interface DocumentEndInput {
scrollY: number;