纯js自动切换图片滑块特效代码

所属分类: 网页特效-图片特效&上传    2024-01-04 10:51:28

纯js自动切换图片滑块特效代码 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

纯js自动切换图片滑块特效代码(共7个文件)

    • index.html

使用方法

document.addEventListener('DOMContentLoaded', function() {
  // sslider = Simple SLIDER
  function sslider() {
    
    var current = 0,
        i,
        slider = document.querySelector('[data-js="sslide"]'),
        allImages =  slider.querySelectorAll('img'),
        imgWidth = Math.ceil(100 / allImages.length),
        sliderWidth = allImages.length * 100;
    
    slider.style.width = sliderWidth + '%';
    
    for(i = 0; i <= allImages.length - 1; i++) {
       allImages[i].style.width = imgWidth + '%';
    }

  function animateRight(cur) {
      var i = imgWidth,
          time = 50;
      var animate = setInterval(function() {
      if(i <= sliderWidth) {
        allImages[cur].style.marginLeft = "-" + i + "%";
        i--;
      } else {
        clearInterval(animate);
      }
      }, time);  
   } 
    
    function reset() {
      for(i = 0; i <= allImages.length - 1; i++) {
        animateRight(i);
      }
      // resseting the current image to the first image
      current = 0;
    }    
    
    function animateLeft(cur) {
      var i = 0,
          time = 50;
      var animate = setInterval(function() {
      if(i <= imgWidth) {
        allImages[cur].style.marginLeft = "-" + i  + "%";
        i++;
      } else {
        clearInterval(animate);
      }
      }, time);  
   }
    
    setInterval(function () {
      if(current <= allImages.length - 2) {
        animateLeft(current);
        current++;
        
      } else {
        reset();
      }
    }, 3000);
} // end
 sslider();
});

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

jquery鼠标悬停或移动端触摸长按图片缩放特效插件

一款鼠标悬停或手机端长按触发的图片特效插件,当鼠标悬停或点击并按住图片时,触发对图片平滑的缩放和动画效果。支持4种自定义图片效果:默认、变焦效果、发光效果、禁用触摸。
  图片特效&上传
 1803  0

jquery原始图片对比插件

一款图片前后比较插件,带三种不同模式:单击切换、悬停跟随、单击递增进度。
  图片特效&上传
 1488  0

jquery移动端带预览删除的上传图片插件代码

一款手机端图片上传特效,支持自定义上传的图片扩展名、图片大小、上传数量等。
  图片特效&上传
 91090  0

jquery全屏图片放大可切换旋转的弹出层插件

zoomifyc是一个功能丰富的图片查看器插件,可以在全屏页面下打开图片,并支持拖动、缩放、切换和旋转。
  图片特效&上传
 6703  0

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

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