question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Masonry component re-renders items that are visible in the viewport while scrolling

See original GitHub issue

I’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:

  1. Go here: https://bvaughn.github.io/react-virtualized/#/components/Masonry
  2. Select checkbox “Use WindowScroller?”
  3. Open Developer Tools
  4. Select a masonry brick and change it’s corresponding <style> tag by adding the following code
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

  1. Set the following CSS properties for the current masonry brick class: animation-name: fadeIn; animation-duration: 1s;
  2. 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:closed
  • Created 6 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
bvaughncommented, Nov 25, 2017

Fix will be released with 9.13.0 shortly.

0reactions
lrholmescommented, Jan 15, 2018

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found