imagesLoaded – 检测网页中的图片是否加载

imagesLoaded 是一个用于来检测网页中的图片是否载入完成的 JavaScript 工具库。支持回调的获取图片加载的进度,还可以绑定自定义事件。可以结合 jQuery、RequireJS 使用。

 

imagesLoaded – 检测网页中的图片是否加载

插件下载     效果演示

 

使用示例:

// element  imagesLoaded( document.querySelector('#container'), function( instance ) {    console.log('all images are loaded');  });  // selector string  imagesLoaded( '#container', function() {...});  // multiple elements  var posts = document.querySelectorAll('.post');  imagesLoaded( posts, function() {...});

绑定自定义事件:

var imgLoad = imagesLoaded( elem );  function onAlways( instance ) {    console.log('all images are loaded');  }  // bind with .on()  imgLoad.on( 'always', onAlways );  // unbind with .off()  imgLoad.off( 'always', onAlways );
赞 (0) 打赏

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏