纯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图片拼成的3D立方体旋转动画特效代码

一款无线循环滚动的3D图片立方体特效,鼠标悬停于某一面上时,自动变为透明色,其它面突出显示。
  图片特效&上传
 1789  0

jquery点击按钮图片左右滚动代码

左右切换箭头为单个图片移动,鼠标移至图片有遮罩显示图片文字内容。
  图片特效&上传
 81036  0

jquery图片相册旋转木马特效

一款支持自定义的幻灯片特效插件,可连续滚动、停止连续滚动、单一张切换等。
  图片特效&上传
 4840  0

jquery带左右箭头可切换的图片弹出放大插件

一款点击弹出图片放大特效,带文字标题和左右箭头切换,非常实用。
  图片特效&上传
 5877  0

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

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