Masonry component re-renders items that are visible in the viewport while scrolling
See original GitHub issueI’m having some performance issues using the Masonry component. Sometimes, when scrolling a page with masonry cells, while they are still visible in the viewport, a re-render is triggered, causing the browser to do a new layout and painting operation for the “new” items, but nothing on them has changed to make them trigger a re-render. This can be seen by using a CSS keyframe animation that’s triggered when an element is added to the DOM. I can also reproduce the issue on the demo page. To reproduce it I do the following steps:
- Go here: https://bvaughn.github.io/react-virtualized/#/components/Masonry
- Select checkbox “Use WindowScroller?”
- Open Developer Tools
- Select a masonry brick and change it’s corresponding <style> tag by adding the following code
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
- Set the following CSS properties for the current masonry brick class:
animation-name: fadeIn; animation-duration: 1s;
- Then scroll on the page and watch the cells animating while they are still in the viewport, you can also see in the elements panel the corresponding elements flashing, meaning they were re-rendered. I would expect them to be only rendered when being added to the DOM on scroll at the bottom or top of the page, depending on the direction of the scroll.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Rendering large lists with React Virtualized - LogRocket Blog
They calculate which items are visible inside the area where the list is displayed (the viewport). They use a container ( div )...
Read more >Rendering Lists Using React Virtualized | CSS-Tricks
isScrolling : Indicates if the scrolling is occurring in the List component. isVisible : Determines if a row is visible or out of...
Read more >React rendering is messing up my ref binding with Masonry
So I have a <ul> list with <li> items that I want to masonry in my React app, and those items will later...
Read more >FlatList · React Native
Internal state is not preserved when content scrolls out of the render window. ... that an item must be either entirely visible or...
Read more >12 Creating the MAF AMX User Interface - Oracle Help Center
When the Panel Group Layout component is not scrollable, its content is ... A tile is represented by the Masonry Layout Item (...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fix will be released with 9.13.0 shortly.
Hi, I’m also having this issue. It’s occurring under the same circumstances described in the OP - an opacity/transform animation on a cell item is being re-rendered while scrolling, making the animation unusable.
I wonder if there is a better or recommended way of handling animation on cell enter?