Coder Social home page Coder Social logo

Comments (1)

exploIF avatar exploIF commented on June 15, 2024

Hi @renochew, I've taken a look on your repro and it looks like it's not Reanimated, FlatList or FlashList issues. This is related to how react native rendering system works. There is no guarantee that fixed sizes passed to the component would be exactly those values (you can read more about it here in caution section).

In your case FlashList is using always the same estimated element size (because of the good memoization) but FlatList is recalculating item size on each render, so sometimes it may be for example 70.90908, sometimes it will be 71.0101 etc. this is causing difference after couple rerenders. Also your elements have width and height of 71 which makes calculation and rounding even more complicated (as it's prime number).

What you can do to fix that is passing already rounded value as an element size, like below:

const ELEMENT_SIZE = 71;
const BLOCK_SIZE = PixelRatio.roundToNearestPixel(ELEMENT_SIZE);

And then use BLOCK_SIZE everywhere in the code like previously (inside scrollTo and obviously as an element width and height too).

from react-native-reanimated.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.