loktar00 / react-lazy-load

React component that renders children elements when they enter the viewport.
MIT License
979 stars 166 forks source link

on page load all items load regardless of offset.. #138

Closed jamesryan-dev closed 2 years ago

jamesryan-dev commented 4 years ago

I've added a callback function to test and upon load, all components wrapped seem to load..

I have tested various offsets with consideration of hero height but it would seem they load regardless..

example code:

import TitleText from '../components/TitleText'
import HomeTitleCopyScene from '../components/HomeTitleCopyScene/index.js'
import CaseStudyCards from '../components/CaseStudyCards'
import LazyLoad from 'react-lazy-load';
import TechUsed from '../components/TechUsed'

function Home() {
  return (
    <div className="container">
      <Banner
        title="Front-end Development and Design"
        copy="With half a decade experience I've worked across a broad spectrum of clients, industries and technologies."
        imageD="white-ipad"
        imageN="black-ipad"
       />
       <LazyLoad offsetVertical={1500} onContentVisible={console.log('loaded1')}>
      <HomeTitleCopyScene />
      </LazyLoad>
      <LazyLoad offsetVertical={1750} onContentVisible={console.log('loaded2')}>
      <CaseStudyCards />
      </LazyLoad>
      <LazyLoad offsetVertical={2000} onContentVisible={console.log('loaded3   ')}>
      <TechUsed displayAll title="The Whole is Greater than the Sum of its Parts" text="A list of all technologies, tools, software and services utilised and skilled in over the last 5 years." all  />
      </LazyLoad>
    </div>
  );
}

export default Home;

had this previously working so not sure if recent pushes have affected this library for anyone else?

krishna-mastree commented 4 years ago

for me too, all components loading by default.

Alexanderwags commented 4 years ago

hello @jimmynames @krishna-mastree , if you could solve the problem?

jamesryan-dev commented 3 years ago

@Alexanderwags hey man sorry im super late - I never found a solution - I intend on trying to find another library time permitting as this one doesn't seem to work

ivanjeremic commented 3 years ago

Same

loktar00 commented 2 years ago

Old issue but getting around to updating/fixing, what browser was this happening in? I recently update the example in https://github.com/loktar00/react-lazy-load/tree/feature/update-to-18 which is a WIP and it seems to be working fine.

loktar00 commented 2 years ago

Should now be fixed in 4.0 with #155