feat: light a chapter when its heading crosses 60% of the viewport
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user