paveisistemas / ionic-image-lazy-load

Directive to Ionic Framework that only loads an image when it is seen by the user.
http://codepen.io/pavei/pen/oFpCy
MIT License
366 stars 117 forks source link

Is there any issue when you dynamically change the image after load? #13

Open jawgardner opened 9 years ago

jawgardner commented 9 years ago

When I use the directive it works fine on initial load, but if i change the src url to some other url in the controller, the change is not reflected in the image.

Any thoughts?

bojanvidanovic commented 9 years ago

You need to observe img tag for changes and fire the load function.

ddtch commented 9 years ago

Have the same issue like. @jawgardner Have you solve this issue? @b0jan can you give more detail instructions ?

bojanvidanovic commented 9 years ago

@sikha here is my solution, don't know if it completely solves your problem. Just edit form line 59.

   $attributes.$observe('imageLazySrc', function(value){
       var deregistration = $scope.$on('lazyScrollEvent', function(){
            if (isInView()) {
                 loadImage();
                 deregistration();
             }
          }
      );
  });
pliablepixels commented 9 years ago

The change by @b0jan works great - I had the same issue and chanced upon this resolution

RavikumarRapolu commented 6 years ago

Hi This plugin is awesome, I am stuck with if image does not exist in url, in that case how to handle on err image, is there any event to check err occured with the image load...