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 );

 

您可能感兴趣的相关文章

 

本文链接:imagesLoaded – 检测网页中的图片是否加载

编译来源:梦想天空 ◆ 关注前端开发技术 ◆ 分享网页设计资源

相关文章:

  • 2021-11-28
  • 2021-10-08
  • 2021-11-28
  • 2022-01-31
  • 2022-12-23
  • 2021-07-10
猜你喜欢
  • 2022-12-23
  • 2021-09-21
  • 2021-05-20
  • 2021-09-12
  • 2022-12-23
  • 2021-12-24
  • 2021-12-27
相关资源
相似解决方案