bvaughn / react-virtualized

React components for efficiently rendering large lists and tabular data
http://bvaughn.github.io/react-virtualized/
MIT License
26.38k stars 3.06k forks source link

Using the MultiGrid isScrolling is only true on the grid that scrolls #1173

Closed mauricedb closed 1 month ago

mauricedb commented 6 years ago

What is the current behavior?

Using the MultiGrid cellRenderer the isScrolling argument is only true on the grid that scrolls, the other grids will always report isScrolling as false.

The downside here is that optimizations to code based on the isScrolling argument can't be done. In my specific case, I get quite a bit of lag with the row headers dragging slower due to drag&drop, context menu and swipe logic in there. As none of that can actually happen when scrolling I want to use the isScrolling argument to render a simpler row header.

See https://codesandbox.io/s/z6921736wx for a working example. Scroll using the mouse wheel or slider bar and observe that only the grid that is scrolled updates the status in the cell.

What is the expected behavior?

I expect the isScrolling argument to be correct in each of the four connected Grid instances.

Which versions of React and react-virtualized, and which browser / OS are affected by this issue? Did this work in previous versions of react-virtualized?

Browser Chrome/FireFox/Edge
OS Windóws 10.1803
React 16.4.1
React DOM 16.4.1
react-virtualized 9.20.1
minicuper commented 6 years ago

it's still there. "version": "9.21.0"

chnakamura commented 3 years ago

I am still experiencing this behavior on version 9.22.3, but I was able to ameliorate it pretty easily by storing the value dataGridIsScrolling in state and forcing one last update after we are done scrolling.

const [dataGridIsScrolling, setDataGridIsScrolling] = useState<boolean>(false);

useEffect(() => {
// This allows us to trigger rendering the tooltips once we have stopped scrolling. 
// We do this because rendering the tooltips while scrolling causes the component to lag,
// and the tooltips are not useful while the grid is scrolling.
if (multiGridRef !== null && dataGridIsScrolling == false) {
    multiGridRef.forceUpdateGrids();
}
}, [dataGridIsScrolling])
...
return <MultiGrid cellRenderer={cellRenderer} ref={ref => setMultiGridRef(ref)} ... />;