MCPcopy Create free account
hub / github.com/bvaughn/react-window / isSelfScrolling

Function isSelfScrolling

lib/utils/scrollElement.ts:67–83  ·  view source on GitHub ↗
(
  containerElement: HTMLElement,
  direction: Direction
)

Source from the content-addressed store, hash-verified

65 * (e.g. a grid that scrolls its columns while rows scroll with the page).
66 */
67export function isSelfScrolling(
68 containerElement: HTMLElement,
69 direction: Direction
70): boolean {
71 const { overflowX, overflowY } =
72 getOwnerWindow(containerElement).getComputedStyle(containerElement);
73 const overflow = direction === "vertical" ? overflowY : overflowX;
74 if (overflow === "visible" || overflow === "clip") {
75 // Rows that overflow their estimated size can't be scrolled to
76 return false;
77 }
78
79 // Allow for rounding (scroll and client sizes are rounded separately, e.g. for fractional item sizes)
80 return direction === "vertical"
81 ? containerElement.scrollHeight - containerElement.clientHeight > 1
82 : containerElement.scrollWidth - containerElement.clientWidth > 1;
83}
84
85/**
86 * Measures the region of the container that is visible within the scroll element's viewport.

Callers 2

useVirtualizerFunction · 0.90

Calls 1

getOwnerWindowFunction · 0.90

Tested by

no test coverage detected