TradeMe / ng-defer-load

MIT License
127 stars 36 forks source link

deferLoad not working in Child Components #20

Open booellean opened 6 years ago

booellean commented 6 years ago

I did not try with the app.module, but I followed the example link pretty closely and this is the only difference I could find.

When deferLoad is used in a child component, it will load all images that are presently in the initial viewport but fail to load any images on new images that come to the viewport thereafter.

BasilioB commented 5 years ago

Yes, i second this. Trieed in app.component: works. Tried in some child component: doesnt work. Any idea why?

BasilioB commented 5 years ago

Ok, I'm gone deeper and found out:

Object.keys(entry).length in line 80 is 0 so the fallback (check page and element offset isVisible()) is taken to check, whether to load the image or not. But entry is an IntersectionObserverEntry with keys and values inside.

Now, all offsets of images where smaller than scrollY + clientHeight, cause they where not loaded and didnt take any space. If I give them space it works. But upper problem still exists.

booellean commented 5 years ago

@BasilioB thank you for checking on that. i'm going to check this out again and see if I can find anything else as well.

tsenguunchik commented 5 years ago

Any update on this?

antonioparraga commented 5 years ago

this component is more like un useful if it does not support child components

keyuls commented 5 years ago

Any update on this?

DavidMarquezF commented 4 years ago

Having the same issue

thesignal commented 3 years ago

Hi, i came across the same issue - in my child module deferLoad wasn't working. The child module (also lazy loaded via route) is a template which I use in an ngFor loop, it lazyloads preview images for each element.

I wanted so dig into it so I set it up as a directive in my project ... and now it's working (just created the directive with "ng generate directive" and copy pasted the code + added the module. I don't have time to look at it now (works, don't care :P ) but might look into it sooner or later. Can't explain why but maybe it helps someone.

NickGeek commented 3 years ago

@thesignal Awesome! If there's any changes you made when you have time it'd be really sweet to get a PR.