fix(createVirtualizer): add window check to resolve the ReferenceError
This commit is contained in:
@@ -258,12 +258,13 @@ export function createVirtualizer<T>(
|
|||||||
// Calculate initial offset ONCE
|
// Calculate initial offset ONCE
|
||||||
const getElementOffset = () => {
|
const getElementOffset = () => {
|
||||||
const rect = node.getBoundingClientRect();
|
const rect = node.getBoundingClientRect();
|
||||||
return rect.top + window.scrollY;
|
const scrollY = typeof window !== 'undefined' ? window.scrollY : 0;
|
||||||
|
return rect.top + scrollY;
|
||||||
};
|
};
|
||||||
|
|
||||||
let cachedOffsetTop = 0;
|
let cachedOffsetTop = 0;
|
||||||
let rafId: number | null = null;
|
let rafId: number | null = null;
|
||||||
containerHeight = window.innerHeight;
|
containerHeight = typeof window !== 'undefined' ? window.innerHeight : 0;
|
||||||
|
|
||||||
const handleScroll = () => {
|
const handleScroll = () => {
|
||||||
if (rafId !== null) {
|
if (rafId !== null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user