twobin / react-lazyload

Lazy load your component, image or anything matters the performance.
MIT License
5.87k stars 488 forks source link

Fixed bug with multiple lazy-loading on 1 screen #246

Open SimonSomlai opened 5 years ago

SimonSomlai commented 5 years ago

Description

This PR is about solving a bug where the vertical lazy loading stopped working when using a vertical and horizontal lazy load together on one page (problem video).

This problem was caused because there was never a scroll listener placed on the window object in this case. This is because both the vertical AND horizontal lazy load containers are using the same "listeners" array.

So when the first (horizontal) lazy load mounts, it adds listeners to the array and when the time comes that the second (vertical) lazy load mounts, the listeners array > 0 and the scroll listener is never attached.

To solve this problem I;

Testing Info

Screenshot 2019-07-30 at 14 29 17
SimonSomlai commented 5 years ago

There also seems to be a problem with the travis build server the last couple of months (not something that I caused). Could you look into this? @ameerthehacker