( el: HTMLElement, state: StreamScrollFollow, thresholdPx = DEFAULT_STREAM_SCROLL_THRESHOLD, )
| 115 | * Pauses when the reader scrolls up; resumes when they return near the bottom. |
| 116 | */ |
| 117 | export function syncStreamScrollFollow( |
| 118 | el: HTMLElement, |
| 119 | state: StreamScrollFollow, |
| 120 | thresholdPx = DEFAULT_STREAM_SCROLL_THRESHOLD, |
| 121 | ): void { |
| 122 | if (isNearScrollBottom(el, thresholdPx)) { |
| 123 | state.paused = false; |
| 124 | state.lastScrollTop = el.scrollTop; |
| 125 | return; |
| 126 | } |
| 127 | |
| 128 | if (el.scrollTop < state.lastScrollTop - 2) { |
| 129 | state.paused = true; |
| 130 | } |
| 131 | |
| 132 | state.lastScrollTop = el.scrollTop; |
| 133 | } |
| 134 | |
| 135 | /** Poll + follow each animation frame while content streams. */ |
| 136 | export function tickStreamScrollFollow( |
no test coverage detected