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

images not get loaded without scrolling #24

Closed payalpatel2299 closed 7 years ago

karensg commented 8 years ago

Same problem here. Solved by adding: $window.scrollBy(0, 1);

rdalfonso commented 8 years ago

@karensg - where did you add that $window.scrollBy(0, 1)? I have img lazy-img inside of a jQuery carousel. First 'N' number of images load and I can see success method firing off, but any subsequent scrolling and the images do not load and no methods firing off.

abunour22 commented 8 years ago

same issue here !!

lourenc commented 7 years ago

@rdalfonso - I have the same issue with a carousel. Basically directive doesn't detect images which are added to DOM dynamically.

So I've tried to to call $window.scrollBy(0, 1) and $rootScope.$emit('lazyImg:refresh');, but it doesn't help at all.

Did somebody manage to fix it?

KevinBeckers commented 7 years ago

Also solved by adding: $window.scrollBy(0, 1); I added it after the the img elements are loaded.

fott1 commented 7 years ago

I show images with ng-repeat. The images are not being loaded until i resize the window. i tried $window.scrollBy(0, 1); but nothing. Any solution?

KevinBeckers commented 7 years ago

Maybe $window.resize() ?

cmddavid commented 7 years ago

Both $window.scrollBy(0, 1) and $rootScope.$emit('lazyImg:refresh'); didn't work for me by default. The lazy image was in a directive inside a ng-repeat rendered by a ui-router view. I did find a solution though: wrapping $rootScope.$emit('lazyImg:refresh'); inside $timeout worked for me.

$timeout(function(){ $rootScope.$emit('lazyImg:refresh'); });

Might be of use to someone :)

Aller05 commented 7 years ago

@cmddavid Your solution for me to solve the problem, now start the page, the current view can be a normal picture. But the timer time I tried many times, at least 600ms, low does not work, do not know why. Set to 1000, more secure $timeout(function(){ $rootScope.$emit('lazyImg:refresh'); },1000);

Pentiado commented 7 years ago

30 should fix it.