MCPcopy Create free account
hub / github.com/Linen-dev/linen.dev / isInViewport

Function isInViewport

packages/utilities/src/scroll.ts:39–50  ·  view source on GitHub ↗
(node: HTMLElement)

Source from the content-addressed store, hash-verified

37}
38
39export function isInViewport(node: HTMLElement) {
40 if (!node) {
41 return false;
42 }
43 const { top, left, bottom, right } = node.getBoundingClientRect();
44 return (
45 top >= 0 &&
46 left >= 0 &&
47 bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
48 right <= (window.innerWidth || document.documentElement.clientWidth)
49 );
50}

Callers 2

handleLeftScrollFunction · 0.90
handleLeftScrollFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected