From fe6c1ad5ed88da3e0050dc4ed13f841fec963d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A5=BF=E9=97=A8?= <1745745@qq.com> Date: Fri, 27 Feb 2015 23:21:29 +0800 Subject: [PATCH] 3.0.0 --- Changelog.md | 36 +++ README.md | 37 +-- full-screen-pic.html | 4 +- full-screen-text.html | 11 +- index.html | 16 +- js/swipeSlide.js | 549 ++++++++++++++++++++---------------------- js/swipeSlide.min.js | 9 +- 7 files changed, 329 insertions(+), 333 deletions(-) create mode 100644 Changelog.md diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..da8a854 --- /dev/null +++ b/Changelog.md @@ -0,0 +1,36 @@ +### 3.0.0(150227) + +* 重构js +* 支持resize +* 修改回调callback写法 + +### 2.2.1(150130) + +* 优化懒加载时js阻塞导致轮播图片无法显示 + +### 2.2(150112) + +* 修复Chrome模拟器touch变鼠标后js报错 +* 修复只有1个轮播时禁止自动切换 + +### 2.1(150105) + +* 支持Windows Phone + +### 2.0(141007) + +* 支持选择连续滚动 +* 支持选择滚动轴 +* 增加过渡效果(cubic-bezier) + +### 1.1(140930) + +* 支持Zepto精简版或jQuery 2.x库,去掉Zepto Touch模块依赖 +* 增加图片跟手滑动 +* 改善部分Android浏览器滑动卡顿 + +### 1.0(140905) + +* 支持选择自动或手动切换 +* 支持改变切换速度 +* 支持图片懒加载 \ No newline at end of file diff --git a/README.md b/README.md index a4a39c2..39f2768 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,11 @@ # swipeSlide for Zepto/jQuery Plugin +## 简介 + 移动端(基于Zepto/jQuery)的轮播插件: +## 示例 + ![扫一扫](website.png) [DEMO链接](http://ons.me/wp-content/uploads/2014/09/swipeSlide/index.html) @@ -11,33 +15,16 @@ ![扫一扫](website-text.png) [DEMO链接](http://ons.me/wp-content/uploads/2014/09/swipeSlide/full-screen-text.html) -### v2.2.1: - -* 优化懒加载时js阻塞导致轮播图片无法显示 - -### v2.2: - -* 修复Chrome模拟器touch变鼠标后js报错 -* 修复只有1个轮播时禁止自动切换 - -### v2.1: - -* 支持Windows Phone - -### v2.0: +## 依赖 -* 支持选择连续滚动 -* 支持选择滚动轴 -* 增加过渡效果(cubic-bezier) +Zepto 或者 jQuery -### v1.1: +## 最新版本 -* 支持Zepto精简版或jQuery 2.x库,去掉Zepto Touch模块依赖 -* 增加图片跟手滑动 -* 改善部分Android浏览器滑动卡顿 +### 3.0.0(150227) -### v1.0: +* 重构js +* 支持resize +* 修改回调callback写法 -* 支持选择自动或手动切换 -* 支持改变切换速度 -* 支持图片懒加载 \ No newline at end of file +[所有更新日志](Changelog.md) \ No newline at end of file diff --git a/full-screen-pic.html b/full-screen-pic.html index 129e064..7e20129 100644 --- a/full-screen-pic.html +++ b/full-screen-pic.html @@ -1,8 +1,8 @@ + - + swipeSlide - @@ -186,9 +191,10 @@

swipeSlide for Zepto/jQuery $('#slide3').swipeSlide({ continuousScroll:true, speed : 3000, - transitionType : 'cubic-bezier(0.22, 0.69, 0.72, 0.88)' - },function(i){ - $('.dot').children().eq(i).addClass('cur').siblings().removeClass('cur'); + transitionType : 'cubic-bezier(0.22, 0.69, 0.72, 0.88)', + callback : function(i){ + $('.dot').children().eq(i).addClass('cur').siblings().removeClass('cur'); + } }); }); diff --git a/js/swipeSlide.js b/js/swipeSlide.js index cad2e49..df692aa 100644 --- a/js/swipeSlide.js +++ b/js/swipeSlide.js @@ -1,345 +1,310 @@ /** - * Zepto swipeSlide Plugin - * 西门 http://ons.me/500.html - * 20150130 v2.2.1 + * swipeSlide + * http://ons.me/500.html + * 西门 + * 3.0(150227) */ - -;(function($){ +;(function(win,$){ 'use strict'; - $.fn.swipeSlide = function(options,callback){ - var _index = 0, - _startX = 0, - _startY = 0, - _moveX = 0, - _moveY = 0, - _moveResultX = 0, - _moveResultY = 0, - _moveDistance = 0, - _curX = 0, - _curY = 0, - autoScroll, - _touchDistance = 50, - _loadPicNum = 0, - firstMovePrev = true, - allowSlideClick = true, - $this = $(this), - browser = { - ie10 : window.navigator.msPointerEnabled, - ie11 : window.navigator.pointerEnabled - }, - events = ['touchstart','touchmove','touchend'], - support = { - touch : (window.Modernizr && Modernizr.touch === true) || (function () { - return !!(('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch); - })() - }, - opts = $.extend({}, { - ul : $this.children('ul'), // 父dom - li : $this.children().children('li'), // 子dom - continuousScroll : false, // 连续滚动 - autoSwipe : true, // 自动切换 - speed : 4000, // 切换速度 - axisX : true, // X轴 - transitionType : 'ease', // 过渡类型 - lazyLoad : false // 懒加载 - }, options || {}), - _liWidth = opts.li.width(), - _liHeight = opts.li.height(), - _liLength = opts.li.length, - callback = callback || function(){}; + + // 判断IE + var browser = { + ie10 : win.navigator.msPointerEnabled, + ie11 : win.navigator.pointerEnabled + }; + // 触摸事件 + var events = ['touchstart','touchmove','touchend']; + // 检测 + var support = { + // 触摸 + touch : (win.Modernizr && Modernizr.touch === true) || (function () { + return !!(('ontouchstart' in win) || win.DocumentTouch && document instanceof DocumentTouch); + })() + }; - // 判断浏览器 - if (browser.ie10) events = ['MSPointerDown', 'MSPointerMove', 'MSPointerUp']; - if (browser.ie11) events = ['pointerdown', 'pointermove', 'pointerup']; + // 判断浏览器 + if (browser.ie10) events = ['MSPointerDown', 'MSPointerMove', 'MSPointerUp']; + if (browser.ie11) events = ['pointerdown', 'pointermove', 'pointerup']; - // 触摸赋值 - var touchEvents = { - touchStart : events[0], - touchMove : events[1], - touchEnd : events[2] - }; + // 触摸赋值 + var touchEvents = { + touchStart : events[0], + touchMove : events[1], + touchEnd : events[2] + }; - // 初始化 - (function(){ - // 如果轮播小于等于1个,跳出 - if(_liLength <= 1){ - fnLazyLoad(0); - return false; - } + // 绑定swipeSlide + $.fn.swipeSlide = function(options){ + new sS(this, options); + }; + var sS = function(element, options){ + var me = this; + me.$el = $(element); + me._index = 0; + me._distance = 50; + me.allowSlideClick = true; + me.init(options); + }; - // 连续滚动,需要复制dom - if(opts.continuousScroll){ - opts.ul.prepend(opts.li.last().clone()).append(opts.li.first().clone()); - if(opts.axisX){ - fnTranslate(opts.ul.children().first(),_liWidth*-1); - fnTranslate(opts.ul.children().last(),_liWidth*_liLength); - }else{ - fnTranslate(opts.ul.children().first(),_liHeight*-1); - fnTranslate(opts.ul.children().last(),_liHeight*_liLength); - } - } + // 初始化 + sS.prototype.init = function(options){ + var me = this; + me.opts = $.extend({}, { + ul : me.$el.children('ul'), // 父dom + li : me.$el.children().children('li'), // 子dom + continuousScroll : false, // 连续滚动 + autoSwipe : true, // 自动切换 + speed : 4000, // 切换速度 + axisX : true, // X轴 + transitionType : 'ease', // 过渡类型 + lazyLoad : false, // 懒加载 + callback : function(){} // 回调方法 + }, options); + // 轮播数量 + me._liLength = me.opts.li.length; - // 懒加载图片 - if(opts.lazyLoad){ - var i = 0; - if(opts.continuousScroll){ - _loadPicNum = 3; - }else{ - _loadPicNum = 2; - } - for(i; i < _loadPicNum; i++){ - fnLazyLoad(i); - } - } + // 如果轮播小于等于1个,跳出 + if(me._liLength <= 1) return false; - // IE触控 - if(browser.ie10 || browser.ie11){ - var action = ''; - if(opts.axisX){ - action = 'pan-y'; - }else{ - action = 'none'; - } - $this.css({'-ms-touch-action':action,'touch-action':action}); - } + // 懒加载图片 + if(me.opts.lazyLoad){ + fnLazyLoad(me, '0'); + fnLazyLoad(me, '1'); + // 加载最后一屏,为了连续滚动复制dom + if(me.opts.continuousScroll) fnLazyLoad(me, me._liLength-1); + } + + // 连续滚动,复制dom + if(me.opts.continuousScroll) me.opts.ul.prepend(me.opts.li.last().clone()).append(me.opts.li.first().clone()); + + // 轮播的宽度 + fnGetSlideDistance(); - // 给初始图片定位 - if(opts.axisX){ - opts.li.each(function(i){ - fnTranslate($(this),_liWidth*i); - }); + if(browser.ie10 || browser.ie11){ + // IE触控 + var action = ''; + if(me.opts.axisX){ + action = 'pan-y'; }else{ - opts.li.each(function(i){ - fnTranslate($(this),_liHeight*i); - }); + action = 'none'; } + me.$el.css({'-ms-touch-action':action,'touch-action':action}); - // 自动滚动 - fnAutoSwipe(); + // 解决IE滑动触发click + me.$el.on('click',function(){ + return me.allowSlideClick; + }); + } - // 回调 - callback(_index); + // 调用轮播 + me.fnAutoSlide(); - $this.on('click',function(){ - return allowSlideClick; - }); + // 回调 + me.opts.callback(me._index); - // 绑定触摸 - $this.on(touchEvents.touchStart,function(e){ - fnTouches(e); - fnTouchstart(e); - }); - $this.on(touchEvents.touchMove,function(e){ - fnTouches(e); - fnTouchmove(e); - }); - $this.on(touchEvents.touchEnd,function(){ - fnTouchend(); - }); - })(); + // 绑定触摸 + me.$el.on(touchEvents.touchStart,function(e){ + fnTouches(e); + fnTouchstart(e, me); + }); + me.$el.on(touchEvents.touchMove,function(e){ + fnTouches(e); + fnTouchmove(e, me); + }); + me.$el.on(touchEvents.touchEnd,function(){ + fnTouchend(me); + }); - // css过渡 - function fnTransition(dom,num){ - dom.css({ - '-webkit-transition':'all '+num+'s '+opts.transitionType, - 'transition':'all '+num+'s '+opts.transitionType + // 横竖屏、窗口调整 + $(win).on('onorientationchange' in win ? 'orientationchange' : 'resize',function(){ + clearTimeout(me.timer); + me.timer = setTimeout(fnGetSlideDistance,150); + }); + + // 获取轮播宽度 + function fnGetSlideDistance(){ + var $li = me.opts.ul.children(); + me._slideDistance = me.opts.axisX ? me.opts.li.width() : me.opts.li.height(); + // 定位 + fnTransition(me, me.opts.ul, 0); + fnTranslate(me, me.opts.ul, -me._slideDistance*me._index); + fnTransition(me, $li, 0); + var num = me.opts.continuousScroll ? -1 : 0; + $li.each(function(i){ + fnTranslate(me, $(this), me._slideDistance*(i+num)); }); } + }; + + // css过渡 + function fnTransition(me, dom, num){ + dom.css({ + '-webkit-transition':'all '+num+'s '+me.opts.transitionType, + 'transition':'all '+num+'s '+me.opts.transitionType + }); + } + + // css位移 + function fnTranslate(me, dom, distance){ + var result = me.opts.axisX ? distance+'px,0,0' : '0,'+distance+'px,0'; + dom.css({ + '-webkit-transform':'translate3d('+result+')', + 'transform':'translate3d('+result+')' + }); + } - // css滚动 - function fnTranslate(dom,result){ - if(opts.axisX){ - dom.css({ - '-webkit-transform':'translate3d(' + result + 'px,0,0)', - 'transform':'translate3d(' + result + 'px,0,0)' - }); + // 懒加载图片 + function fnLazyLoad(me, index){ + var $li = me.opts.ul.children(); + var $thisImg = $li.eq(index).find('[data-src]'); + if($thisImg){ + if($thisImg.is('img')){ + $thisImg.attr('src',$thisImg.data('src')); + $thisImg.removeAttr('data-src'); }else{ - dom.css({ - '-webkit-transform':'translate3d(0,' + result + 'px,0)', - 'transform':'translate3d(0,' + result + 'px,0)' - }); + $thisImg.css({'background-image':'url('+$thisImg.data('src')+')'}); + $thisImg.removeAttr('data-src'); } } + } - // 懒加载图片 - function fnLazyLoad(index){ - if(opts.lazyLoad){ - var $li = opts.ul.children(); - var $thisImg = $li.eq(index).find('[data-src]'); - if($thisImg){ - if($thisImg.is('img')){ - $thisImg.attr('src',$thisImg.data('src')); - $thisImg.removeAttr('data-src'); - }else{ - $thisImg.css({'background-image':'url('+$thisImg.data('src')+')'}); - $thisImg.removeAttr('data-src'); - } - } - } + // touches + function fnTouches(e){ + if(support.touch && !e.touches){ + e.touches = e.originalEvent.touches; } + } - // touches - function fnTouches(e){ - if(support.touch && !e.touches){ - e.touches = e.originalEvent.touches; - } - } + // touchstart + function fnTouchstart(e, me){ + // 按下时的坐标 + me._startX = support.touch ? e.touches[0].pageX : (e.pageX || e.clientX); + me._startY = support.touch ? e.touches[0].pageY : (e.pageY || e.clientY); + } - // touchstart - function fnTouchstart(e){ - _startX = support.touch ? e.touches[0].pageX : (e.pageX || e.clientX); - _startY = support.touch ? e.touches[0].pageY : (e.pageY || e.clientY); - } + // touchmove + function fnTouchmove(e, me){ + if (e.preventDefault) e.preventDefault(); + else e.returnValue = false; + // 如果自动切换,move的时候清除autoSlide自动轮播方法 + if(me.opts.autoSwipe) clearInterval(me.autoSlide); + me.allowSlideClick = false; + // 触摸时的坐标 + me._curX = support.touch ? e.touches[0].pageX : (e.pageX || e.clientX); + me._curY = support.touch ? e.touches[0].pageY : (e.pageY || e.clientY); + // 触摸时的距离 + me._moveX = me._moveX_ie = me._curX - me._startX; + me._moveY = me._moveY_ie = me._curY - me._startY; - // touchmove - function fnTouchmove(e){ - if (e.preventDefault) e.preventDefault(); - else e.returnValue = false; - if(opts.autoSwipe){ - clearInterval(autoScroll); - } - allowSlideClick = false; - _curX = support.touch ? e.touches[0].pageX : (e.pageX || e.clientX); - _curY = support.touch ? e.touches[0].pageY : (e.pageY || e.clientY); - _moveX = _moveResultX = _curX - _startX; - _moveY = _moveResultY = _curY - _startY; - fnTransition(opts.ul,0); - if(opts.axisX){ - if(!opts.continuousScroll){ - if(_index == 0 && _moveResultX > 0){ - _moveResultX = 0; - return fnAutoSwipe(); - }else if((_index + 1) >= _liLength && _moveResultX < 0){ - _moveResultX = 0; - return fnAutoSwipe(); - } - } - fnTranslate(opts.ul,-(_liWidth * (parseInt(_index)) - _moveResultX)); - }else{ - if(!opts.continuousScroll){ - if(_index == 0 && _moveResultY > 0){ - _moveResultY = 0; - return fnAutoSwipe(); - }else if((_index + 1) >= _liLength && _moveResultY < 0){ - _moveResultY = 0; - return fnAutoSwipe(); - } - } - fnTranslate(opts.ul,-(_liHeight * (parseInt(_index)) - _moveResultY)); + // 触摸时跟手 + fnTransition(me, me.opts.ul, 0); + // 距离 + me._moveDistance = me._moveDistanceIE = me.opts.axisX ? me._moveX : me._moveY; + if(!me.opts.continuousScroll){ + // 如果是第一屏,并且往下滚动,就不让滚动 || 如果是最后一屏,并且往上滚动,就不让滚动 + if(me._index == 0 && me._moveDistance > 0 || (me._index + 1) >= me._liLength && me._moveDistance < 0){ + me._moveDistance = 0; } } + // 触摸时跟手滚动 + fnTranslate(me, me.opts.ul, -(me._slideDistance * me._index - me._moveDistance)); + } - // touchend - function fnTouchend(){ - if(opts.axisX){ - _moveDistance = _moveResultX; - }else{ - _moveDistance = _moveResultY; - } - + // touchend + function fnTouchend(me){ + if(browser.ie10 || browser.ie11){ // 解决IE滑动触发click - if(Math.abs(_moveX) < 5){ - allowSlideClick = true; + if(Math.abs(me._moveDistanceIE) < 5){ + me.allowSlideClick = true; } setTimeout(function(){ - allowSlideClick = true; + me.allowSlideClick = true; },100); + } - // 距离小 - if(Math.abs(_moveDistance) <= _touchDistance){ - fnScroll(.3); - // 距离大 + // 距离小 + if(Math.abs(me._moveDistance) <= me._distance){ + fnSlide(me, '', '.3'); + // 距离大 + }else{ + // 手指触摸上一屏滚动 + if(me._moveDistance > me._distance){ + fnSlide(me, 'prev', '.3'); + // 手指触摸下一屏滚动 }else{ - // 手指触摸上一屏滚动 - if(_moveDistance > _touchDistance){ - fnMovePrev(); - fnAutoSwipe(); - // 手指触摸下一屏滚动 - }else if(_moveDistance < -_touchDistance){ - fnMoveNext(); - fnAutoSwipe(); - } + fnSlide(me, 'next', '.3'); } - _moveX = _moveResultX = 0,_moveY = _moveResultY = 0; } + me.fnAutoSlide(); + me._moveDistance = me._moveDistanceIE = 0; + } - // 滚动方法 - function fnScroll(num){ - fnTransition(opts.ul,num); - if(opts.axisX){ - fnTranslate(opts.ul,-_index*_liWidth); - }else{ - fnTranslate(opts.ul,-_index*_liHeight); - } + // 自动轮播 + sS.prototype.fnAutoSlide = function(){ + var me = this; + if(me.opts.autoSwipe){ + me.autoSlide = setInterval(function(){ + fnSlide(me, 'next', '.3'); + },me.opts.speed); } + }; - // 滚动判断 - function fnMove(){ - if(opts.continuousScroll){ - if(_index >= _liLength){ - fnScroll(.3); - _index = 0; - setTimeout(function(){ - fnScroll(0); - },300); - }else if(_index < 0){ - fnScroll(.3); - _index = _liLength-1; - setTimeout(function(){ - fnScroll(0); - },300); + // 轮播方法 + function fnSlide(me, direction, num){ + // 判断方向 + if(direction == 'next'){ + me._index++; + if(me.opts.lazyLoad){ + // 因为连续滚动,复制dom,所以要多加1 + if(me.opts.continuousScroll){ + fnLazyLoad(me, me._index+2); }else{ - fnScroll(.3); - } - }else{ - if(_index >= _liLength){ - _index = 0; - }else if(_index < 0){ - _index = _liLength-1; + fnLazyLoad(me, me._index+1); } - fnScroll(.3); } - callback(_index); - } - - // 下一屏滚动 - function fnMoveNext(){ - _index++; - fnMove(); - if(opts.lazyLoad){ - if(opts.continuousScroll){ - fnLazyLoad(_index+2); + }else if(direction == 'prev'){ + me._index--; + // 往上滚动比较特殊,只有连续滚动&&懒加载时才有 + if(me.opts.lazyLoad && me.opts.continuousScroll){ + if(me._index < 0){ + fnLazyLoad(me, me._liLength-1); }else{ - fnLazyLoad(_index+1); + fnLazyLoad(me, me._index); } } } - - // 上一屏滚动 - function fnMovePrev(){ - _index--; - fnMove(); - // 第一次往右滚动懒加载图片 - if(firstMovePrev && opts.lazyLoad){ - var i = _liLength-1; - for(i; i <= (_liLength+1); i++){ - fnLazyLoad(i); - } - firstMovePrev = false; - return; - } - if(!firstMovePrev && opts.lazyLoad){ - fnLazyLoad(_index); + // 如果是连续滚动 + if(me.opts.continuousScroll){ + if(me._index >= me._liLength){ + fnScroll(me, num); + me._index = 0; + setTimeout(function(){ + fnScroll(me, 0); + },300); + }else if(me._index < 0){ + fnScroll(me, num); + me._index = me._liLength-1; + setTimeout(function(){ + fnScroll(me, 0); + },300); + }else{ + fnScroll(me, num); } - } - - // 自动滚动 - function fnAutoSwipe(){ - if(opts.autoSwipe){ - autoScroll = setInterval(function(){ - fnMoveNext(); - },opts.speed); + }else{ + if(me._index >= me._liLength){ + me._index = 0; + }else if(me._index < 0){ + me._index = me._liLength-1; } + fnScroll(me, num); } + me.opts.callback(me._index); + } + + // 轮播动作 + function fnScroll(me, num){ + fnTransition(me, me.opts.ul, num); + fnTranslate(me, me.opts.ul, -me._index*me._slideDistance); } -})(window.Zepto || window.jQuery); \ No newline at end of file + +})(window, window.Zepto || window.jQuery); \ No newline at end of file diff --git a/js/swipeSlide.min.js b/js/swipeSlide.min.js index ba4916e..2c29c8c 100644 --- a/js/swipeSlide.min.js +++ b/js/swipeSlide.min.js @@ -1,6 +1,7 @@ /** - * Zepto swipeSlide Plugin - * 西门 http://ons.me/500.html - * 20150130 v2.2.1 + * swipeSlide + * http://ons.me/500.html + * 西门 + * 3.0(150227) */ -!function(a){"use strict";a.fn.swipeSlide=function(b,c){function B(a,b){a.css({"-webkit-transition":"all "+b+"s "+w.transitionType,transition:"all "+b+"s "+w.transitionType})}function C(a,b){w.axisX?a.css({"-webkit-transform":"translate3d("+b+"px,0,0)",transform:"translate3d("+b+"px,0,0)"}):a.css({"-webkit-transform":"translate3d(0,"+b+"px,0)",transform:"translate3d(0,"+b+"px,0)"})}function D(a){var b,c;w.lazyLoad&&(b=w.ul.children(),c=b.eq(a).find("[data-src]"),c&&(c.is("img")?(c.attr("src",c.data("src")),c.removeAttr("data-src")):(c.css({"background-image":"url("+c.data("src")+")"}),c.removeAttr("data-src"))))}function E(a){v.touch&&!a.touches&&(a.touches=a.originalEvent.touches)}function F(a){e=v.touch?a.touches[0].pageX:a.pageX||a.clientX,f=v.touch?a.touches[0].pageY:a.pageY||a.clientY}function G(a){if(a.preventDefault?a.preventDefault():a.returnValue=!1,w.autoSwipe&&clearInterval(n),r=!1,l=v.touch?a.touches[0].pageX:a.pageX||a.clientX,m=v.touch?a.touches[0].pageY:a.pageY||a.clientY,g=i=l-e,h=j=m-f,B(w.ul,0),w.axisX){if(!w.continuousScroll){if(0==d&&i>0)return i=0,M();if(d+1>=z&&0>i)return i=0,M()}C(w.ul,-(x*parseInt(d)-i))}else{if(!w.continuousScroll){if(0==d&&j>0)return j=0,M();if(d+1>=z&&0>j)return j=0,M()}C(w.ul,-(y*parseInt(d)-j))}}function H(){k=w.axisX?i:j,Math.abs(g)<5&&(r=!0),setTimeout(function(){r=!0},100),Math.abs(k)<=o?I(.3):k>o?(L(),M()):-o>k&&(K(),M()),g=i=0,h=j=0}function I(a){B(w.ul,a),w.axisX?C(w.ul,-d*x):C(w.ul,-d*y)}function J(){w.continuousScroll?d>=z?(I(.3),d=0,setTimeout(function(){I(0)},300)):0>d?(I(.3),d=z-1,setTimeout(function(){I(0)},300)):I(.3):(d>=z?d=0:0>d&&(d=z-1),I(.3)),c(d)}function K(){d++,J(),w.lazyLoad&&(w.continuousScroll?D(d+2):D(d+1))}function L(){if(d--,J(),q&&w.lazyLoad){var a=z-1;for(a;z+1>=a;a++)D(a);return q=!1,void 0}!q&&w.lazyLoad&&D(d)}function M(){w.autoSwipe&&(n=setInterval(function(){K()},w.speed))}var n,A,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,o=50,p=0,q=!0,r=!0,s=a(this),t={ie10:window.navigator.msPointerEnabled,ie11:window.navigator.pointerEnabled},u=["touchstart","touchmove","touchend"],v={touch:window.Modernizr&&Modernizr.touch===!0||function(){return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)}()},w=a.extend({},{ul:s.children("ul"),li:s.children().children("li"),continuousScroll:!1,autoSwipe:!0,speed:4e3,axisX:!0,transitionType:"ease",lazyLoad:!1},b||{}),x=w.li.width(),y=w.li.height(),z=w.li.length;c=c||function(){},t.ie10&&(u=["MSPointerDown","MSPointerMove","MSPointerUp"]),t.ie11&&(u=["pointerdown","pointermove","pointerup"]),A={touchStart:u[0],touchMove:u[1],touchEnd:u[2]},function(){var b,e;if(1>=z)return D(0),!1;if(w.continuousScroll&&(w.ul.prepend(w.li.last().clone()).append(w.li.first().clone()),w.axisX?(C(w.ul.children().first(),-1*x),C(w.ul.children().last(),x*z)):(C(w.ul.children().first(),-1*y),C(w.ul.children().last(),y*z))),w.lazyLoad)for(b=0,p=w.continuousScroll?3:2,b;p>b;b++)D(b);(t.ie10||t.ie11)&&(e="",e=w.axisX?"pan-y":"none",s.css({"-ms-touch-action":e,"touch-action":e})),w.axisX?w.li.each(function(b){C(a(this),x*b)}):w.li.each(function(b){C(a(this),y*b)}),M(),c(d),s.on("click",function(){return r}),s.on(A.touchStart,function(a){E(a),F(a)}),s.on(A.touchMove,function(a){E(a),G(a)}),s.on(A.touchEnd,function(){H()})}()}}(window.Zepto||window.jQuery); \ No newline at end of file +!function(a,b){"use strict";function h(a,b,c){b.css({"-webkit-transition":"all "+c+"s "+a.opts.transitionType,transition:"all "+c+"s "+a.opts.transitionType})}function i(a,b,c){var d=a.opts.axisX?c+"px,0,0":"0,"+c+"px,0";b.css({"-webkit-transform":"translate3d("+d+")",transform:"translate3d("+d+")"})}function j(a,b){var c=a.opts.ul.children(),d=c.eq(b).find("[data-src]");d&&(d.is("img")?(d.attr("src",d.data("src")),d.removeAttr("data-src")):(d.css({"background-image":"url("+d.data("src")+")"}),d.removeAttr("data-src")))}function k(a){e.touch&&!a.touches&&(a.touches=a.originalEvent.touches)}function l(a,b){b._startX=e.touch?a.touches[0].pageX:a.pageX||a.clientX,b._startY=e.touch?a.touches[0].pageY:a.pageY||a.clientY}function m(a,b){a.preventDefault?a.preventDefault():a.returnValue=!1,b.opts.autoSwipe&&clearInterval(b.autoSlide),b.allowSlideClick=!1,b._curX=e.touch?a.touches[0].pageX:a.pageX||a.clientX,b._curY=e.touch?a.touches[0].pageY:a.pageY||a.clientY,b._moveX=b._moveX_ie=b._curX-b._startX,b._moveY=b._moveY_ie=b._curY-b._startY,h(b,b.opts.ul,0),b._moveDistance=b._moveDistanceIE=b.opts.axisX?b._moveX:b._moveY,b.opts.continuousScroll||(0==b._index&&b._moveDistance>0||b._index+1>=b._liLength&&b._moveDistance<0)&&(b._moveDistance=0),i(b,b.opts.ul,-(b._slideDistance*b._index-b._moveDistance))}function n(a){(c.ie10||c.ie11)&&(Math.abs(a._moveDistanceIE)<5&&(a.allowSlideClick=!0),setTimeout(function(){a.allowSlideClick=!0},100)),Math.abs(a._moveDistance)<=a._distance?o(a,"",".3"):a._moveDistance>a._distance?o(a,"prev",".3"):o(a,"next",".3"),a.fnAutoSlide(),a._moveDistance=a._moveDistanceIE=0}function o(a,b,c){"next"==b?(a._index++,a.opts.lazyLoad&&(a.opts.continuousScroll?j(a,a._index+2):j(a,a._index+1))):"prev"==b&&(a._index--,a.opts.lazyLoad&&a.opts.continuousScroll&&(a._index<0?j(a,a._liLength-1):j(a,a._index))),a.opts.continuousScroll?a._index>=a._liLength?(p(a,c),a._index=0,setTimeout(function(){p(a,0)},300)):a._index<0?(p(a,c),a._index=a._liLength-1,setTimeout(function(){p(a,0)},300)):p(a,c):(a._index>=a._liLength?a._index=0:a._index<0&&(a._index=a._liLength-1),p(a,c)),a.opts.callback(a._index)}function p(a,b){h(a,a.opts.ul,b),i(a,a.opts.ul,-a._index*a._slideDistance)}var f,g,c={ie10:a.navigator.msPointerEnabled,ie11:a.navigator.pointerEnabled},d=["touchstart","touchmove","touchend"],e={touch:a.Modernizr&&Modernizr.touch===!0||function(){return!!("ontouchstart"in a||a.DocumentTouch&&document instanceof DocumentTouch)}()};c.ie10&&(d=["MSPointerDown","MSPointerMove","MSPointerUp"]),c.ie11&&(d=["pointerdown","pointermove","pointerup"]),f={touchStart:d[0],touchMove:d[1],touchEnd:d[2]},b.fn.swipeSlide=function(a){new g(this,a)},g=function(a,c){var d=this;d.$el=b(a),d._index=0,d._distance=50,d.allowSlideClick=!0,d.init(c)},g.prototype.init=function(d){function o(){var c,a=e.opts.ul.children();e._slideDistance=e.opts.axisX?e.opts.li.width():e.opts.li.height(),h(e,e.opts.ul,0),i(e,e.opts.ul,-e._slideDistance*e._index),h(e,a,0),c=e.opts.continuousScroll?-1:0,a.each(function(a){i(e,b(this),e._slideDistance*(a+c))})}var g,e=this;return e.opts=b.extend({},{ul:e.$el.children("ul"),li:e.$el.children().children("li"),continuousScroll:!1,autoSwipe:!0,speed:4e3,axisX:!0,transitionType:"ease",lazyLoad:!1,callback:function(){}},d),e._liLength=e.opts.li.length,e._liLength<=1?!1:(e.opts.lazyLoad&&(j(e,"0"),j(e,"1"),e.opts.continuousScroll&&j(e,e._liLength-1)),e.opts.continuousScroll&&e.opts.ul.prepend(e.opts.li.last().clone()).append(e.opts.li.first().clone()),o(),(c.ie10||c.ie11)&&(g="",g=e.opts.axisX?"pan-y":"none",e.$el.css({"-ms-touch-action":g,"touch-action":g}),e.$el.on("click",function(){return e.allowSlideClick})),e.fnAutoSlide(),e.opts.callback(e._index),e.$el.on(f.touchStart,function(a){k(a),l(a,e)}),e.$el.on(f.touchMove,function(a){k(a),m(a,e)}),e.$el.on(f.touchEnd,function(){n(e)}),b(a).on("onorientationchange"in a?"orientationchange":"resize",function(){clearTimeout(e.timer),e.timer=setTimeout(o,150)}),void 0)},g.prototype.fnAutoSlide=function(){var a=this;a.opts.autoSwipe&&(a.autoSlide=setInterval(function(){o(a,"next",".3")},a.opts.speed))}}(window,window.Zepto||window.jQuery); \ No newline at end of file