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

Function lockStreamHeight

src/hold-stream.ts:30–49  ·  view source on GitHub ↗
(
  el: HTMLElement,
  streaming: boolean,
  options?: { domUpdated?: boolean },
)

Source from the content-addressed store, hash-verified

28 * inner overflow (e.g. max-height grids) cannot trap page scroll.
29 */
30export function lockStreamHeight(
31 el: HTMLElement,
32 streaming: boolean,
33 options?: { domUpdated?: boolean },
34): void {
35 if (!streaming) {
36 el.style.minHeight = "";
37 return;
38 }
39
40 const domUpdated = options?.domUpdated !== false;
41 const h = el.offsetHeight;
42 const prev = Number.parseFloat(el.style.minHeight) || 0;
43
44 if (h > prev) {
45 el.style.minHeight = `${h}px`;
46 } else if (domUpdated && h < prev) {
47 el.style.minHeight = h > 0 ? `${h}px` : "";
48 }
49}
50
51/** Clear height lock when streaming finishes */
52export function unlockStreamHeight(el: HTMLElement): void {

Callers 2

streamhtml.tsxFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected