网络编程 
首页 > 网络编程 > 浏览文章

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

(编辑:jimmy 日期: 2024/10/26 浏览:3 次 )

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

效果图:

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">

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

上一篇:JavaScript实现英语单词题库
下一篇:微信小程序自定义模态弹窗组件详解
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。