适用于手机端的jQuery图片滑块动画

编程学习 2021-07-04 19:19www.dzhlxh.cn编程入门
这篇文章主要为大家分享了适应手机端的jQuery图片滑块动画,不仅在PC浏览器上可以使用,而且更适合在手机端的网页中使用,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了基于jQuery实现的手机端图片滑块动画源码,供大家参考,具体内容如下

效果图:

实例代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>适应手机端的jQuery图片滑块动画DEMO演示</title>
<link rel="stylesheet" href="/api/jq/5733e37626dcb/css/style.css" />
<script src="/api/jq/5733e37626dcb/js/islider.js"></script>
<script src="/api/jq/5733e37626dcb/js/plugins/islider_desktop.js"></script>
</head>
<body>
<!-- 代码 开始 -->
<!--<h4 style="text-align: center">animateType参数中设置,目前支持default, rotate, flip 和 depth, 点击按钮看效果</h4>-->
<div id="iSlider-effect-wrapper">
 <div id="animation-effect" class="iSlider-effect"></div>
</div>
<div id="menu-select">
 <span class="on">default</span>
 <span>rotate</span>
 <span>flip</span>
 <span>depth</span>
</div>
<h4 style="text-align: center">垂直轮播</h4>
<div id="vertical-slide" class="iSlider-effect"></div>
<h4 style="text-align: center">不循环模式(最始及最末图片滑动会有衰减效果)</h4>
<div id="non-looping" class="iSlider-effect"></div>
<h4 style="text-align: center">DOM</h4>
<div id="dom-effect" class="iSlider-effect"></div>
<script>
  var picList = [
  {
   width: 150,
   height: 207,
   content: "/api/jq/5733e37626dcb/images/1.jpg",
  },
  {
   width: 150,
   height: 207,
   content: "/api/jq/5733e37626dcb/images/2.jpg",
  },
  {
   width: 150,
   height: 207,
   content: "/api/jq/5733e37626dcb/images/3.jpg",
  },
  {
   width: 150,
   height: 207,
   content:"/api/jq/5733e37626dcb/images/5.jpg"
  },
  {
   width: 150,
   height: 207,
   content:"/api/jq/5733e37626dcb/images/6.jpg"
  },
  {
   width: 300,
   height: 414,
   content:"/api/jq/5733e37626dcb/images/7.jpg"
  },
  {
   width: 150,
   height: 207,
   content:"/api/jq/5733e37626dcb/images/8.jpg"
  },
  {
   width: 150,
   height: 207,
   content:"/api/jq/5733e37626dcb/images/9.jpg"
  }
  ];
  var domList = [
  {
   'height' : '100%',
   'width' : '100%',
   'content' : '<div><h1>Home</h1><h2>This is home page</h2><p>home is pretty awsome</p><div>'
  },{
   'height' : '100%',
   'width' : '100%',
   'content' : '<div><h1>Page1</h1><h2>This is page1</h2><p>page1 is pretty awsome</p><div>'
  },{
   'height' : '100%',
   'width' : '100%',
   'content' : '<div><h1>Page2</h1><h2>This is Page2</h2><p>Page2 is pretty awsome</p><div>'
  },{
   'height' : '100%',
   'width' : '100%',
   'content' : '<div><h1>Page3</h1><h2>This is page3</h2><p>page3 is pretty awsome</p><div>'
  }
  ];
  //all animation effect
  var islider1 = new iSlider({
   data: picList,
   dom: document.getElementById("animation-effect"),
   duration: 2000,
   animateType: 'default',
   isAutoplay: true,
   isLooping: true,
   // isVertical: true, 是否垂直滚动
  });
  islider1.bindMouse();
  //vertical slide
  var islider2 = new iSlider({
   data: picList,
   dom: document.getElementById("vertical-slide"),
   duration: 2000,
   animateType: 'default',
   isVertical: true,
   isAutoplay: true,
   isLooping: true,
  });
  islider2.bindMouse();
  //不循环 不自动播放
  var islider3 = new iSlider({
   data: picList,
   dom: document.getElementById("non-looping"),
   animateType: 'default',
  });
  islider3.bindMouse();
  //滚动dom
  var islider4 = new iSlider({
   data: domList,
   dom: document.getElementById("dom-effect"),
   type: 'dom',
   animateType: 'default',
   isAutoplay: true,
   isLooping: true,
  });
  islider4.bindMouse();
  var menu = document.getElementById('menu-select').children;
  function clickMenuActive(target) {
   for (var i = 0; i < menu.length; i++) {
    menu[i].className = '';
   }
   target.className = 'on';
  }
  menu[0].onclick = function() {
   clickMenuActive(this);
   islider1._opts.animateType = this.innerHTML;
   islider1.reset();
  };
  menu[1].onclick = function() {
   clickMenuActive(this);
   islider1._opts.animateType = this.innerHTML;
   islider1.reset();
  };
  menu[2].onclick = function() {
   clickMenuActive(this);
   islider1._opts.animateType = this.innerHTML;
   islider1.reset();
  };
  menu[3].onclick = function() {
   clickMenuActive(this);
   islider1._opts.animateType = this.innerHTML;
   islider1.reset();
  };
</script>
<!-- 代码 结束 -->
</body>
</html>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持狼蚁SEO。

Copyright © 2016-2025 www.dzhlxh.cn 金源码 版权所有 Power by

网站模板下载|网络推广|微博营销|seo优化|视频营销|网络营销|微信营销|网站建设|织梦模板|小程序模板