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

Function easeScrollTop

src/hold-stream.ts:63–76  ·  view source on GitHub ↗
(
  el: HTMLElement,
  targetTop: number,
  factor = DEFAULT_STREAM_SCROLL_EASE,
)

Source from the content-addressed store, hash-verified

61 * Use inside a requestAnimationFrame loop while content streams.
62 */
63export function easeScrollTop(
64 el: HTMLElement,
65 targetTop: number,
66 factor = DEFAULT_STREAM_SCROLL_EASE,
67): boolean {
68 const target = Math.max(0, targetTop);
69 const delta = target - el.scrollTop;
70 if (Math.abs(delta) < 0.5) {
71 el.scrollTop = target;
72 return true;
73 }
74 el.scrollTop += delta * factor;
75 return false;
76}
77
78/** Ease a scroll container toward its bottom edge */
79export function easeScrollToBottom(

Callers 2

easeScrollToBottomFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected