当前位置:首页 >> 网络编程

iSlider手机端图片滑动切换插件使用详解

自适应轮播图,支持手机触屏滑动,三种切换效果。

效果图:

iSlider手机端图片滑动切换插件使用详解

js:

var iSlider = function(opts) {
 if (!opts.dom) {
  throw new Error("dom element can not be empty!");
 }
 if (!opts.data || !opts.data.length) {
  throw new Error("data must be an array and must have more than one element!");
 }
 this._opts = opts;
 this._setting();
 this._renderHTML();
 this._bindHandler();
};
iSlider.prototype._setting = function() {
 var opts = this._opts;
 this.wrap = opts.dom;
 this.data = opts.data;
 this.type = opts.type || 'pic';
 this.isVertical = opts.isVertical || false;
 this.onslide = opts.onslide;
 this.onslidestart = opts.onslidestart;
 this.onslideend = opts.onslideend;
 this.onslidechange = opts.onslidechange;
 this.duration = opts.duration || 4000;
 this.log = opts.isDebug "X") "Y": "X";
  var absoluteOffset = Math.abs(offset);
  var bdColor = window.getComputedStyle(this.wrap.parentNode, null).backgroundColor;
  if (this.isVertical) {
   offset = -offset;
  }
  this.wrap.style.webkitPerspective = scale * 4;
  if (i == 1) {
   dom.style.zIndex = scale - absoluteOffset;
  } else {
   dom.style.zIndex = (offset > 0) "X") "Y": "X";
  var bdColor = window.getComputedStyle(this.wrap.parentNode, null).backgroundColor;
  if (this.isVertical) {
   offset = -offset;
  }
  this.wrap.style.webkitPerspective = scale * 4;
  if (offset > 0) {
   dom.style.visibility = (i > 1) "X") "Y": "X";
  var zoomScale = (4 - Math.abs(i - 1)) * 0.15;
  this.wrap.style.webkitPerspective = scale * 4;
  if (i == 1) {
   dom.style.zIndex = 100;
  } else {
   dom.style.zIndex = (offset > 0) "X") "Y": "X";
  var zoomScale = 1 - (Math.abs(i - 1) * 0.2);
  this.wrap.style.webkitPerspective = scale * 4;
  if (i == 1) {
   dom.style.zIndex = 100;
  } else {
   dom.style.zIndex = (offset > 0) "' + this.height + '" src="/UploadFiles/2021-04-02/' + item.content + '">
<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <title>Document</title>
 <style type="text/css">
  *{
   padding: 0;
   list-style: none;
   margin: 0;
  }
  /*容器高度*/
  #iSlider-effect-wrapper {
   height: 400px;
   width: 500px;
   margin: 0 auto;
   margin-top: 4.6rem;
   overflow: hidden;
   position: relative;
  }
  .iSlider-effect ul{
   list-style: none;
   padding: 0;
   margin: 0;
   height: 100%;
   overflow: hidden
  }
  .iSlider-effect li {
   position: absolute;
   margin: 0;
   padding: 0;
   height: 100%;
   overflow: hidden;
   display: -webkit-box;
   -webkit-box-pack: center;
   -webkit-box-align: center;
   list-style: none
  }
  .iSlider-effect ul li img {
   max-width: 100%;
   max-height: 100%;
   margin: 0;
   padding: 0
  }
  .iSlider-effect div {
   background-color: #fff;
   padding: 3px
  }
 </style>
</head>
<body>
 <script type="text/javascript" src="/UploadFiles/2021-04-02/mobile_slider.js">

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