纯javascript实现的图片延迟加载特效代码

所属分类: 网页特效-预加载    2024-01-31 11:43:22

纯javascript实现的图片延迟加载特效代码 ie兼容6
反馈问题  查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

纯javascript实现的图片延迟加载特效代码(共40个文件)

    • image-12.jpg
    • image-6.jpg
    • shimmer-effect.gif
    • image-4.jpg
    • image-6-small.jpg
    • image-11.jpg
    • image-10.jpg
    • index.html

使用方法

class BlurryImageLoad {
  supportsCSSFilters(enableWebkit) {
    if (enableWebkit === undefined) {
      enableWebkit = false;
    }
    //creating an element dynamically
    const element = document.createElement("test");
    //adding filter-blur property to it
    element.style.cssText =
      (enableWebkit ? "-webkit-" : "") + "filter: blur(2px)";
    //checking whether the style is computed or ignored
    const test1 = element.style.length != 0;
    //checking for false positives of IE
    //I prefer Modernizr's smart method of browser detection
    const test2 =
      document.documentMode === undefined || document.documentMode > 9;
    //non-IE browsers, including ancient IEs
    //IE compatibility mode
    //combining test results
    return test1 && test2;
  }

  load(...images) {
    // Make all DOM elements with the class blurry-load the default value of the images parameter
    if (images.length === 0) {
      images = document.querySelectorAll(".blurry-load");
    }

    /* Fallback for browsers that don't support support CSS filters (mainly IE)
      If the browser doesn't support CSS filters,
      display a gray background with a shimmer gradient (see the CSS class no-blur for details) */
    if (!this.supportsCSSFilters(true) && !this.supportsCSSFilters(false)) {
      /* If the browser does not support CSS filters
        Checks with and without the -webkit- prefix */
      for (let image of images) {
        image.src = "";
        image.classList.add("no-blur");
        image.classList.remove("blurry-load");
      }
    }

    for (let image of images) {
      const currentImage = new Image();
      currentImage.src = image.getAttribute("data-large");

      // The main function that loads each image once the page has loaded
      currentImage.onload = () => {
        image.src = currentImage.src;
        image.classList.add("blur-out");
        image.classList.remove("blurry-load");
      };
    }
  }
}

站长提示:
1. 平台上所有素材资源,需注册登录会员方能正常下载。
2. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励20K币
3. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
4. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 预加载

jquery下拉菜单延迟误操作插件-hoverIntent

鼠标hover事件延迟触发动作,很实用的特效!
  预加载
 165  

jquery鼠标悬停自动预加载链接资源特效代码

当鼠标悬停在某个元素链接的时候,将自动预加载链接的页面。当点击链接的时候,就会快速的显示出该页面。
  预加载
 155  

jquery.lazyrate.js延迟加载图片插件

一款图片延迟加载特效,需增加自定义标签data-src配合src实用。
  预加载
 192  

jquery网页预加载动画特效

访问加载页面时,先触发载入loading动画,待页面解析完成后自动消失!
  预加载
 181  

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论