Giter VIP home page Giter VIP logo

Comments (7)

prchando avatar prchando commented on August 21, 2024

Well if I use throttling, then also same issue will occur but in a different measure

It is important to render elements from top to bottom to avoid flicking experiece of the page

from react-lazyload.

jasonslyvia avatar jasonslyvia commented on August 21, 2024

Hi @prchando , I believe there are 2 ways to solve this issue:

  1. pass debounce={false} throttle={false} to disable all delay function, but it's not recommended because you might suffer from frequent updates and maybe visual lags
  2. set appropriate height props for every lazy loaded images, doing this ensures that when users scroll down, while the image is not loaded, the place it will occupy is rendered, so no more flicking.
<LazyLoad height={300}>
  <img src="my-cat.png" width={200} height={300} />
</LazyLoad>

from react-lazyload.

prchando avatar prchando commented on August 21, 2024

@jasonslyvia Well contents are dynamic in nature, you never know the height based on the dynamic data or different image.
For responsive image (), it even becomes more difficult.

from react-lazyload.

prchando avatar prchando commented on August 21, 2024

@jasonslyvia It would be also optimum to provide a hook for loading the resources not only when user scroll but when it is idle. So essentially while we can render page fast without rendering hidden parts, it is good to load hidden parts proactively before scroll, if it is idle

from react-lazyload.

jasonslyvia avatar jasonslyvia commented on August 21, 2024

I'm afraid without a well-assumed height for your lazy loaded components, it would be tough to 'lazy load' them.

Imagine a document populated with lazy loaded components, at the first render, the document is blank, which means the document has no height, how can you determine if the lazy loaded components should become visible?

It would be possible to render them one by one, and check viewport size change and visibility after each one rendered, but it's over optimized and will cause unnecessary rerender.

from react-lazyload.

prchando avatar prchando commented on August 21, 2024

@jasonslyvia I tried with placeholder and that makes things better with original problem. Thanks
You can close this topic

from react-lazyload.

jasonslyvia avatar jasonslyvia commented on August 21, 2024

Glad you work it out, btw, placeholder is another way to set height, but by CSS not props.

from react-lazyload.

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.