fix: window scroller grid remeasure on size change
This commit is contained in:
parent
bf653849d6
commit
43ab38db72
@ -1,4 +1,4 @@
|
|||||||
import { ReactNode, useRef } from 'react';
|
import { ReactNode, useEffect, useRef } from 'react';
|
||||||
import { useWindowVirtualizer } from '@tanstack/react-virtual';
|
import { useWindowVirtualizer } from '@tanstack/react-virtual';
|
||||||
import { useResizeObserver } from 'usehooks-ts';
|
import { useResizeObserver } from 'usehooks-ts';
|
||||||
|
|
||||||
@ -27,6 +27,10 @@ export const WindowScrollerGrid = <D extends any>({ rowSize, colSize, items, chi
|
|||||||
scrollingDelay: 0
|
scrollingDelay: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
virtualizer.measure();
|
||||||
|
}, [rowSize, colSize, virtualizer]);
|
||||||
|
|
||||||
return (<div ref={listRef} className={width <= 0 ? `invisible` : ''}>
|
return (<div ref={listRef} className={width <= 0 ? `invisible` : ''}>
|
||||||
{width > 0 && <div className="w-full relative" style={{
|
{width > 0 && <div className="w-full relative" style={{
|
||||||
height: `${virtualizer.getTotalSize()}px`
|
height: `${virtualizer.getTotalSize()}px`
|
||||||
|
Loading…
Reference in New Issue
Block a user