纯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. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 图片特效&上传

javascript带缩略图的图片切换特效

一款焦点图切换插件,鼠标点击缩略图即可切换到任意一张图片,在图片切换时带有淡入淡出的动画特效。在图片切换时网页的背景颜色也会随着改变,这个你可以自己设置。
  图片特效&上传
 7852  0

jquery轻量级响应式不规则边框幻灯片插件

一款不规则边框的图片轮播插件,插件大小只有3KB,超轻量级!
  图片特效&上传
 2809  0

原生js图片反向动画拆分滚动效果

一款很有趣的图片滚动特效,拉动滚动条上下两组图片反方向拆分。
  图片特效&上传
 6838  0

jquery功能丰富的图片查看器插件

一款功能强大的图片查看器插件,鼠标点击缩略图可弹出大图,可在全屏lightbox中打开图片,支持拖动、缩放和旋转。
  图片特效&上传
 7921  0

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

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