Spaces:
Sleeping
Sleeping
File size: 907 Bytes
23d418f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | // The Architecture page's scroll logic (the content is architecture.json; the layouts
// are the diagram components).
/** Which step is being read: the last one whose top has passed the reading line (a
* fraction of the scroll area's height from its top), so the step under the reader's
* eyes lights its boxes up (scrollytelling: the step crossing the middle is active).
* tops: each step's top relative to the scroll area, in order. -1 = none reached yet. */
export function activeStep(tops: number[], height: number, line = 0.45): number {
let active = -1
tops.forEach((top, i) => {
if (top <= height * line) active = i
})
return active
}
/** A box is lit when the active step names it; with no active step nothing is dimmed. */
export function boxState(id: string, lit: string[] | null): 'lit' | 'dim' | 'plain' {
if (!lit) return 'plain'
return lit.includes(id) ? 'lit' : 'dim'
}
|