MCPcopy Create free account
hub / github.com/Alphanimble/htmlstream / syncStreamScrollFollow

Function syncStreamScrollFollow

src/hold-stream.ts:117–133  ·  view source on GitHub ↗
(
  el: HTMLElement,
  state: StreamScrollFollow,
  thresholdPx = DEFAULT_STREAM_SCROLL_THRESHOLD,
)

Source from the content-addressed store, hash-verified

115 * Pauses when the reader scrolls up; resumes when they return near the bottom.
116 */
117export 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. */
136export function tickStreamScrollFollow(

Callers 4

streamhtml.tsxFile · 0.90
tickStreamScrollFollowFunction · 0.85
onScrollFunction · 0.85

Calls 1

isNearScrollBottomFunction · 0.85

Tested by

no test coverage detected