ensureVisible function

Last updated: 2026-03-05T20:45:07.036Z

Metrics

LOC: 10 Complexity: 4 Params: 1

Signature

ensureVisible(el: Element): : void

Summary

Scrolls element into view if it lies outside the visible viewport. Uses instant scrolling to avoid animations that would delay replay timing.

Source Code

function ensureVisible(el: Element): void {
  const rect = el.getBoundingClientRect();
  const inViewport =
    rect.top >= 0 &&
    rect.bottom <=
      (window.innerHeight || document.documentElement.clientHeight);
  if (!inViewport) {
    el.scrollIntoView({ behavior: "instant", block: "center" });
  }
}

No outgoing dependencies.

Impact (Incoming)

graph LR ensureVisible["ensureVisible"] handleFill["handleFill"] handleClick["handleClick"] handleSelect["handleSelect"] handleCheck["handleCheck"] handleClear["handleClear"] handleFill -->|calls| ensureVisible handleClick -->|calls| ensureVisible handleSelect -->|calls| ensureVisible handleCheck -->|calls| ensureVisible handleClear -->|calls| ensureVisible style ensureVisible fill:#dbeafe,stroke:#2563eb,stroke-width:2px click ensureVisible "12336ba1f5ec5dde.html" click handleFill "8f674e688d002684.html" click handleClick "4b4f336a7104e106.html" click handleSelect "3c2550d444ab28e5.html" click handleCheck "925d9bcf5b79be5d.html" click handleClear "9ce51648e6aea0e1.html"
SourceType
handleFill calls
handleClick calls
handleSelect calls
handleCheck calls
handleClear calls