Pentiado / angular-lazy-img

Lightweight lazy load images plugin. Only 1kb after gziping. Pure JavaScript, only Angular as dependency.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

images not get loaded without scrolling

payalpatel2299 opened this issue · comments

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

@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.

same issue here !!

@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?

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

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?

Maybe $window.resize() ?

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 :)

@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);

#30 should fix it.