MCPcopy Index your code
hub / github.com/TanStack/virtual / observeWindowRect

Function observeWindowRect

packages/virtual-core/src/index.ts:115–134  ·  view source on GitHub ↗
(
  instance: Virtualizer<Window, any>,
  cb: (rect: Rect) => void,
)

Source from the content-addressed store, hash-verified

113}
114
115export const observeWindowRect = (
116 instance: Virtualizer<Window, any>,
117 cb: (rect: Rect) => void,
118) => {
119 const element = instance.scrollElement
120 if (!element) {
121 return
122 }
123
124 const handler = () => {
125 cb({ width: element.innerWidth, height: element.innerHeight })
126 }
127 handler()
128
129 element.addEventListener('resize', handler, addEventListenerOptions)
130
131 return () => {
132 element.removeEventListener('resize', handler)
133 }
134}
135
136const supportsScrollend =
137 typeof window == 'undefined' ? true : 'onscrollend' in window

Callers

nothing calls this directly

Calls 1

handlerFunction · 0.85

Tested by

no test coverage detected