Pentiado / angular-lazy-img

Lightweight lazy load images plugin. Only 1kb after gziping. Pure JavaScript, only Angular as dependency.
MIT License
178 stars 66 forks source link

Fix for "lazy loading not working untill scroll" - Always listen when we set a new image source #30

Closed stevebrowndotco closed 7 years ago

stevebrowndotco commented 8 years ago

First off, great directive.

A lot of users are reporting that the lazy loading logic does not work for images already in the viewport, and that they have to force a scroll to get them to load. #27 #24

The reason for this is probably because they are using routing such as ngRoute or ui-router. What is happening is that there is a "listening trap" occurring. When new images sources are being instantiated, we aren't triggering a listen for the new images and "isElementInView" is never reached until we scroll (or trigger window resize) This is because listening is already running without adding the new image to the array.

This PR always starts listening when a new image is added and fixes the problem, however if anyone has a better solution i'd love to hear it.

abunour22 commented 8 years ago

the issue still exists !!

stevebrowndotco commented 7 years ago

@abunour22 do you mean after checking this branch?