Skip to content

Commit

Permalink
[ lazyload error ]
Browse files Browse the repository at this point in the history
- add error handler to normal lazy load
- add readme docu for lazyload error event
  • Loading branch information
simeydotme committed Feb 21, 2016
1 parent 6b0ecd4 commit c19b516
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.markdown
Expand Up @@ -182,7 +182,8 @@ init | event, slick | When Slick initializes for the first time callback. Note t
reInit | event, slick | Every time Slick (re-)initializes callback
setPosition | event, slick | Every time Slick recalculates position
swipe | event, slick, direction | Fires after swipe/drag
lazyLoaded | event, slick, image | Fires after image loads lazily
lazyLoaded | event, slick, image, imageSource | Fires after image loads lazily
lazyLoadError | event, slick, image, imageSource | Fires after image fails to load


#### Methods
Expand Down
15 changes: 13 additions & 2 deletions slick/slick.js
Expand Up @@ -1474,6 +1474,17 @@

};

imageToLoad.onerror = function() {

image
.removeAttr( 'data-lazy' )
.removeClass( 'slick-loading' )
.addClass( 'slick-lazyload-error' );

_.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);

};

imageToLoad.src = imageSource;

});
Expand Down Expand Up @@ -1667,13 +1678,13 @@

} else {

_.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);

image
.removeAttr( 'data-lazy' )
.removeClass( 'slick-loading' )
.addClass( 'slick-lazyload-error' );

_.$slider.trigger('lazyLoadError', [ _, image, imageSource ]);

_.progressiveLazyLoad();

}
Expand Down

0 comments on commit c19b516

Please sign in to comment.