javascript - jQuery Lazy Load XT - Force Image Load On Custom Event -
i have custom event switchslideevent
firing each time switchslide() method called jquery carousel plugin no documentation.
i using lazy load xt (https://github.com/ressio/lazy-load-xt) lazy load images, however, plugin loads images on following events load
orientationchange
resize
scroll
.
lazy load xt initialized so:
$.extend($.lazyloadxt, { selector: 'img[data-original]', srcattr: 'data-original', edgey: 200, updateevent: 'load orientationchange resize scroll switchslideevent' });
i've tried following solutions, haven't had success:
- pass
switchslideevent
lazy load xtupdateevent
option (seen above) - manually re-initialize lazy load xt
.on('switchslideevent')
so:
i'm getting console.log events, carousel images "slid" view not loading until scroll page.
$(document).ready(function(){ $(document).on('switchslideevent', function(){ console.log("custom event fired"); $(window).lazyloadxt(); }); });
question
how can force lazy load xt load new images when switchslideevent
fires?
any appreciated.
thanks!
within switchslide()
method of carousel plugin, there animate
method complete
callback function. added event $.event.trigger("switchslideanimateevent")
within complete
callback function , adjusted initialization code follows:
$.extend($.lazyloadxt, { selector: 'img[data-original]', srcattr: 'data-original', edgey: 200, updateevent: 'load orientationchange resize scroll switchslideevent switchslideanimateevent' });
i removed $(document).on(switchslideevent)
handler not necessary , images loading properly.
cheers.
Comments
Post a Comment