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

So my scroll container is not $window. And am not able to implement it in particular controller #33

Closed salilbajaj closed 7 years ago

salilbajaj commented 7 years ago

in my app.js i wrote app.config(['lazyImgConfigProvider', function(lazyImgConfigProvider){
setTimeout(function(){ var scrollable = document.querySelector('#int-scroll'); lazyImgConfigProvider.setOptions({ offset: 100, errorClass: 'error', onError: function(image){}, onSuccess: function(image){}, container: angular.element(scrollable) });
},1000)
}]);

So I am using lazy load in listing page. But app.config runs on first load. So if I refresh the listing page(whole app on listing page),it works fine. But when i come from home page it does not work because app.config wont run again.

I want to run the code above when i reach listing controller. Please help

Pentiado commented 7 years ago

You need to add "lazy-img-container" attribute to container and it will work. For example check /demo/container-demo.html