From 1cb692475d8e2036367f6605b80538e3b3d66c46 Mon Sep 17 00:00:00 2001 From: shinate Date: Thu, 17 Mar 2016 14:10:32 +0800 Subject: [PATCH 1/9] addData method append --- build/iSlider.js | 21 +++++++++++ build/iSlider.min.js | 2 +- demo/add_dynamic_data.html | 74 ++++++++++++++++++++++++++++++++++++++ demo/public/js/iSlider.js | 21 +++++++++++ src/js/iSlider.js | 21 +++++++++++ 5 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 demo/add_dynamic_data.html diff --git a/build/iSlider.js b/build/iSlider.js index 58ca207b..5d29863c 100644 --- a/build/iSlider.js +++ b/build/iSlider.js @@ -1690,6 +1690,27 @@ this.fire('loadData slideChanged', this.slideIndex, this.currentEl, this); }; + /** + * Add dynamic data + * + * @param {Object|Array} sceneData + * @description + * Object: + * {content:...} + * Array: + * [{content:...}, {content:...}, ...] + */ + iSliderPrototype.addData = function (sceneData) { + var len = this.data.length; + this.data = this.data.concat(sceneData); + console.log('addData', len - 1 === this.slideIndex); + if (this.isLooping && this.slideIndex === 0) { + this._renderItem(this.els[0], this.data.length - 1); + } else if (len - 1 === this.slideIndex) { + this._renderItem(this.els[2], len); + } + }; + /** * auto check to play and bind events * @private diff --git a/build/iSlider.min.js b/build/iSlider.min.js index c6378c8c..31bd2d0c 100644 --- a/build/iSlider.min.js +++ b/build/iSlider.min.js @@ -1 +1 @@ -!function(t){"use strict";function e(){}function i(t,e){return e.indexOf(t)>-1}function n(t){return"[object Array]"===Object.prototype.toString.call(t)}function s(t){return"[object Object]"===Object.prototype.toString.call(t)}function a(t,e){return t.className.match(new RegExp("(\\s|^)("+e+")(\\s|$)"))}function r(t,e){a(t,e)||(t.className+=" "+e)}function h(t,e){a(t,e)&&(t.className=t.className.replace(RegExp("(\\s|^)("+e+")(\\s|$)"),"$3"))}function o(t){return/<\/?[^>]*>/.test(t)?!1:/^(?:(https|http|ftp|rtsp|mms):)?(\/\/)?(\w+:{0,1}\w*@)?([^\?#:\/]+\.[a-z]+|\d+\.\d+\.\d+\.\d+)?(:[0-9]+)?((?:\.?\/)?([^\?#]*)?(\?[^#]+)?(#.+)?)?$/.test(t)}function l(t){return Array.prototype.slice.apply(t,Array.prototype.slice.call(arguments,1))}var d=function(){var t=l(arguments,0,3);if(!t.length)throw new Error("Parameters required!");var e=s(t.slice(-1)[0])?t.pop():{};switch(t.length){case 2:e.data=e.data||t[1];case 1:e.dom=e.dom||t[0]}if(!e.dom)throw new Error("Container can not be empty!");if(!e.data||!e.data.length)throw new Error("Data must be an array and must have more than one element!");this._opts=e,e=null,t=null,this._setting(),this.fire("initialize"),this._renderWrapper(),this._initPlugins(),this._bindHandler(),this.fire("initialized"),this._autoPlay()};d.VERSION="2.1.4",d.EVENTS=["initialize","initialized","pluginInitialize","pluginInitialized","renderComplete","slide","slideStart","slideEnd","slideChange","slideChanged","slideRestore","slideRestored","loadData","reset","destroy"],d.EASING=[["linear","ease","ease-in","ease-out","ease-in-out"],/cubic-bezier\(([^\d]*(\d+.?\d*)[^\,]*\,?){4}\)/],d.FIX_PAGE_TAGS=["SELECT","INPUT","TEXTAREA","BUTTON","LABEL"],d.NODE_TYPE={unknown:"unknown",empty:"empty",pic:"pic",dom:"dom",html:"html",node:"node",element:"element"},d.TRANSITION_END_EVENT=function(){var t=document.createElement("fakeElement"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(var i in e)if(e.hasOwnProperty(i)&&void 0!==t.style[i])return e[i];return null}(),d.DEVICE_EVENTS=function(){var e=!!("ontouchstart"in t&&!/Mac OS X /.test(t.navigator.userAgent)||t.DocumentTouch&&document instanceof t.DocumentTouch);return{hasTouch:e,startEvt:e?"touchstart":"mousedown",moveEvt:e?"touchmove":"mousemove",endEvt:e?"touchend":"mouseup",cancelEvt:e?"touchcancel":"mouseout",resizeEvt:"onorientationchange"in t?"orientationchange":"resize"}}(),d.extend=function(){var t,e,i=arguments;switch(i.length){case 0:return;case 1:t=d.prototype,e=i[0];break;case 2:t=i[0],e=i[1]}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},d.plugins={},d.regPlugin=function(t,e){d.plugins[t]=d.plugins[t]||e},d._animateFuncs={normal:function(){function t(t,e,i,n,s){t.style.webkitTransform="translateZ(0) translate"+e+"("+(s+i*(n-1))+"px)"}return t.effect="transform",t}()};var c=d.prototype;c.extend=d.extend,c._setting=function(){var s=this;s._plugins=d.plugins,s._animateFuncs=d._animateFuncs,s._holding=!1,s._locking=!1,s._intermediateScene=null,s._transitionEndHandler=null,s._LSN={autoPlay:null,resize:null,transitionEnd:null},s.currentEl=null,s._EventHandle={},s.onMoving=!1,s.onSliding=!1,s.direction=null;var a=this._opts;s.wrap=a.dom,s.data=a.data,s.isVertical=!!a.isVertical,s.isOverspread=!!a.isOverspread,s.duration=a.duration||2e3,s.initIndex=a.initIndex>0&&a.initIndex<=a.data.length-1?a.initIndex:0,s.fixPage=function(){var t=a.fixPage;return t===!1||0===t?!1:n(t)&&t.length>0||"string"==typeof t&&""!==t?[].concat(t).toString():!0}(),s.fillSeam=!!a.fillSeam,s.slideIndex=s.slideIndex||s.initIndex||0,s.axis=s.isVertical?"Y":"X",s.reverseAxis="Y"===s.axis?"X":"Y",s.width="number"==typeof a.width?a.width:s.wrap.offsetWidth,s.height="number"==typeof a.height?a.height:s.wrap.offsetHeight,s.ratio=s.height/s.width,s.scale=s.isVertical?s.height:s.width,s.offset=s.offset||{X:0,Y:0},s.isTouchable=null==a.isTouchable?!0:!!a.isTouchable,s.isLooping=a.isLooping&&s.data.length>1?!0:!1,s.delay=a.delay||0,s.isAutoplay=a.isAutoplay&&s.data.length>1?!0:!1,s.animateType=a.animateType in s._animateFuncs?a.animateType:"normal",s._animateFunc=s._animateFuncs[s.animateType],s._animateReverse=function(){var t=[];for(var e in s._animateFuncs)s._animateFuncs.hasOwnProperty(e)&&s._animateFuncs[e].reverse&&t.push(e);return t}(),s.isVertical&&"card"===s.animateType&&(s.isOverspread=!0),s.log=a.isDebug?function(){t.console.log.apply(t.console,arguments)}:e,s._damping=function(){var t=s.scale>>1,e=t>>1,i=e>>2;return function(n){var s,a=Math.abs(n);return s=t>a?a>>1:t+e>a?e+(a-t>>2):e+i+(a-t-e>>3),n>0?s:-s}}(),s.animateTime=null!=a.animateTime&&a.animateTime>-1?a.animateTime:300,s.animateEasing=i(a.animateEasing,d.EASING[0])||d.EASING[1].test(a.animateEasing)?a.animateEasing:"ease",s.deviceEvents=d.DEVICE_EVENTS,s.fingerRecognitionRange=a.fingerRecognitionRange>-1?parseInt(a.fingerRecognitionRange):10,s.events={},d.EVENTS.forEach(function(t){var e=a["on"+t.toLowerCase()];"function"==typeof e&&s.on(t,e,1)}),s.pluginConfig=function(){var t={};return n(a.plugins)&&a.plugins.forEach(function(e){n(e)?t[e[0]]=e.slice(1):"string"==typeof e&&(t[e]=[])}),t}()},c._initPlugins=function(){var t=this.pluginConfig,e=this._plugins;for(var i in t)t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&e[i]&&"function"==typeof e[i]&&typeof e[i].apply&&e[i].apply(this,t[i]);this.fire("pluginInitialized")},c._itemType=function(t){if(isNaN(t)||(t=this.data[t]),t.hasOwnProperty("type"))return t.type;var e,i=t.content,n=d.NODE_TYPE;return e=null==i?n.empty:Boolean(i.nodeName)&&Boolean(i.nodeType)?n.node:"string"==typeof i?o(i)?n.pic:n.html:n.unknown,t.type=e,e},c._renderItem=function(t,e){var i,n=this,s=this.data.length,a=function(){var e=' src="'+i.content+'"';e+=i.height/i.width>n.ratio?' height="100%"':' width="100%"',n.isOverspread&&(t.style.cssText+="background-image:url("+i.content+");background-repeat:no-repeat;background-position:50% 50%;background-size:cover",e+=' style="display:block;opacity:0;height:100%;width:100%;"'),t.innerHTML=""};if(t.innerHTML="",t.style.background="",this.isLooping||null!=this.data[e]){e=(s+e)%s,i=this.data[e];var r=this._itemType(i),h=d.NODE_TYPE;switch(t.className="islider-"+r,r){case h.pic:if(2===i.load)a();else{var o=new Image;o.src=i.content,o.onload=function(){i.height=o.height,i.width=o.width,a(),i.load=2}}break;case h.dom:case h.html:t.innerHTML=i.content;break;case h.node:case h.element:if(11===i.content.nodeType){var l=document.createElement("div");l.appendChild(i.content),i.content=l}t.appendChild(i.content)}}},c._renderIntermediateScene=function(){null!=this._intermediateScene&&(this._renderItem.apply(this,this._intermediateScene),this._intermediateScene=null)},c._changedStyles=function(){var t=["islider-prev","islider-active","islider-next"];this.els.forEach(function(e,i){h(e,t.join("|")),r(e,t[i]),this.fillSeam&&this.originScale(e)}.bind(this))},c._renderWrapper=function(){var e;this.outer?(e=this.outer,e.innerHTML=""):e=document.createElement("ul"),e.className="islider-outer",this.els=[];for(var i=0;3>i;i++){var n=document.createElement("li");this.els.push(n),this._animateFunc(n,this.axis,this.scale,i,0),this.fixPage||(n.style.overflow="auto"),!this.isVertical||"rotate"!==this.animateType&&"flip"!==this.animateType?this._renderItem(n,i-1+this.slideIndex):this._renderItem(n,1-i+this.slideIndex),e.appendChild(n)}this._changedStyles(),this.fillSeam&&this.els.forEach(function(t,e){r(t,"islider-sliding"+(1===e?"-focus":""))}),t.setTimeout(function(){this._preloadImg(this.slideIndex)}.bind(this),200),this.outer||(this.outer=e,this.wrap.appendChild(e)),this.currentEl=this.els[1],this.fire("renderComplete",this.slideIndex,this.currentEl,this)},c._preloadImg=function(t){if(this.data.length>3){var e=this.data,i=e.length,n=this,s=function(t){var i=e[t];if("pic"===n._itemType(i)&&!i.load){var s=new Image;s.src=i.content,s.onload=function(){i.width=s.width,i.height=s.height,i.load=2},i.load=1}};s((t+2)%i),s((t-2+i)%i)}},c._watchTransitionEnd=function(e,i){this._unWatchTransitionEnd();var n=function(){this._unWatchTransitionEnd(),"slideChanged"===i&&this._changedStyles(),this.fire.call(this,i,this.slideIndex,this.currentEl,this),this._renderIntermediateScene(),this.play(),this.onSliding=!1,this.direction=null}.bind(this);d.TRANSITION_END_EVENT?(this.currentEl.addEventListener(d.TRANSITION_END_EVENT,n),this._transitionEndHandler={el:this.currentEl,handler:n}):this._LSN.transitionEnd=t.setTimeout(n,e)},c._unWatchTransitionEnd=function(){this._LSN.transitionEnd&&t.clearTimeout(this._LSN.transitionEnd),null!==this._transitionEndHandler&&(this._transitionEndHandler.el.removeEventListener(d.TRANSITION_END_EVENT,this._transitionEndHandler.handler),this._transitionEndHandler=null)},c._bindHandler=function(){var e=this.outer,i=this.deviceEvents;this.isTouchable&&(i.hasTouch||(e.style.cursor="pointer",e.ondragstart=function(t){return t?!1:!0}),e.addEventListener(i.startEvt,this),e.addEventListener(i.moveEvt,this),e.addEventListener(i.endEvt,this),!i.hasTouch&&e.addEventListener("mouseout",this)),t.addEventListener(i.resizeEvt,this),t.addEventListener("focus",this,!1),t.addEventListener("blur",this,!1)},c.handleEvent=function(t){var e=this.deviceEvents;switch(t.type){case"mousedown":if(0!==t.button)break;case"touchstart":this.startHandler(t);break;case e.moveEvt:this.moveHandler(t);break;case e.endEvt:case e.cancelEvt:this.endHandler(t);break;case e.resizeEvt:this.resizeHandler();break;case"focus":this.play();break;case"blur":this.pause()}},c.startHandler=function(t){if(this.fixPage&&d.FIX_PAGE_TAGS.indexOf(t.target.tagName.toUpperCase())<0&&!this._isItself(t.target)&&t.preventDefault(),!this._holding&&!this._locking){var e=this.deviceEvents;this.onMoving=!0,this.pause(),this.fire("slideStart",t,this),this.startTime=(new Date).getTime(),this.startX=e.hasTouch?t.targetTouches[0].pageX:t.pageX,this.startY=e.hasTouch?t.targetTouches[0].pageY:t.pageY}},c.moveHandler=function(t){if(this.onMoving){var e=this.deviceEvents,i=this.data.length,n=this.axis,s=this.reverseAxis,a={};t.hasOwnProperty("offsetRatio")?(a[n]=t.offsetRatio*this.scale,a[s]=0):(a.X=e.hasTouch?t.targetTouches[0].pageX-this.startX:t.pageX-this.startX,a.Y=e.hasTouch?t.targetTouches[0].pageY-this.startY:t.pageY-this.startY),this.offset=a,t.offsetRatio=a[n]/this.scale,Math.abs(a[n])-Math.abs(a[s])>10&&(t.preventDefault(),this._unWatchTransitionEnd(),this.isLooping||(a[n]>0&&0===this.slideIndex||a[n]<0&&this.slideIndex===i-1)&&(a[n]=this._damping(a[n])),this.els.forEach(function(t,e){t.style.visibility="visible",t.style.webkitTransition="none",this._animateFunc(t,n,this.scale,e,a[n],a[n]),this.fillSeam&&this.seamScale(t)}.bind(this)),this.fire("slide",t,this))}},c.endHandler=function(e){function i(n){if(null!=n)if("A"===n.tagName){if(n.href)return"_blank"===n.getAttribute("target")?t.open(n.href):t.location.href=n.href,e.preventDefault(),!1}else{if("LI"===n.tagName&&n.className.search(/^islider\-/)>-1)return!1;i(n.parentNode)}}if(this.onMoving){this.onMoving=!1;var n=this.offset,s=this.axis,a=this.scale/2,r=(new Date).getTime(),h=this.fingerRecognitionRange;a=r-this.startTime>300?a:14;var o=Math.abs(n[s]),l=Math.abs(n[this.reverseAxis]);this.fire("slideEnd",e,this),n[s]>=a&&o>l?this.slideTo(this.slideIndex-1):n[s]<-a&&o>l?this.slideTo(this.slideIndex+1):Math.abs(this.offset[s])>=h&&this.slideTo(this.slideIndex),Math.abs(this.offset[s])=1e3&&n&&t.clearInterval(n)}.bind(this),12)):(n&&t.clearTimeout(n),n=t.setTimeout(function(){(this.height!==this.wrap.offsetHeight||this.width!==this.wrap.offsetWidth)&&(n&&t.clearInterval(n),this.reset())}.bind(this),200))},c.slideTo=function(t,e){if(this.isAutoplay&&this.pause(),!this._locking){this.unhold(),this.onSliding=!0;var n,s=this.animateTime,a=this.animateType,o=this._animateFunc,l=this.data,d=this.els,c=this.axis,u=t,f=t-this.slideIndex,p=this.offset,g=0;"object"==typeof e&&(e.animateTime>-1&&(s=e.animateTime),"string"==typeof e.animateType&&e.animateType in this._animateFuncs&&(a=e.animateType,o=this._animateFuncs[a])),0!==p[c]&&(g=Math.abs(p[c])/this.scale*s),Math.abs(f)>1&&this._renderItem(f>0?this.els[2]:this.els[0],u),this._preloadImg(u),l[u]?this.slideIndex=u:this.isLooping?this.slideIndex=f>0?0:l.length-1:f=0;var m,v,E;0===f?n="slideRestore":((this.isVertical&&i(a,this._animateReverse))^f>0?(d.push(d.shift()),m=d[2],v=d[0],E=1):(d.unshift(d.pop()),m=d[0],v=d[2],E=-1),this.currentEl=d[1],1===Math.abs(f)?(this._renderIntermediateScene(),this._renderItem(m,u+f)):Math.abs(f)>1&&(this._renderItem(m,u+E),this._intermediateScene=[v,u-E]),m.style.webkitTransition="none",g=s-g,n="slideChange",this.fillSeam&&(d.forEach(function(t){h(t,"islider-sliding|islider-sliding-focus")}),r(this.currentEl,"islider-sliding-focus"),r(m,"islider-sliding")),this.direction=E);for(var _=0;3>_;_++)d[_]!==m&&(d[_].style.webkitTransition=(o.effect||"all")+" "+g+"ms "+this.animateEasing),o.call(this,d[_],c,this.scale,_,0,E),this.fillSeam&&this.seamScale(d[_]);this._watchTransitionEnd(g,n+"d"),this.fire(n,this.slideIndex,this.currentEl,this)}},c.slideNext=function(){this.slideTo.apply(this,[this.slideIndex+1].concat(l(arguments)))},c.slidePrev=function(){this.slideTo.apply(this,[this.slideIndex-1].concat(l(arguments)))},c.regPlugin=function(){var t=l(arguments),e=t.shift(),n=t[0];(this._plugins.hasOwnProperty(e)||"function"==typeof n)&&("function"==typeof n&&(this._plugins[e]=n,t.shift()),i(e,this._opts.plugins)||(this._opts.plugins.push(t.length?[].concat([e],t):e),"function"==typeof this._plugins[e]&&this._plugins[e].apply(this,t)))},c.bind=c.delegate=function(e,i,n){function s(e){for(var s=t.event?t.event:e,a=s.target,r=document.querySelectorAll(i),h=0;h-1)return this.wrap.removeEventListener(t,this._EventHandle[n][1][s]),this._EventHandle[n][0][s]=this._EventHandle[n][1][s]=null,!0}return!1},c.destroy=function(){var e=this.outer,i=this.deviceEvents;this.fire("destroy"),this.isTouchable&&(e.removeEventListener(i.startEvt,this),e.removeEventListener(i.moveEvt,this),e.removeEventListener(i.endEvt,this),!i.hasTouch&&e.removeEventListener("mouseout",this)),t.removeEventListener(i.resizeEvt,this),t.removeEventListener("focus",this),t.removeEventListener("blur",this);var n;for(n in this._EventHandle)for(var s=this._EventHandle[n][1],a=0;a-1&&delete this.events[t][i]}},c.fire=function(t){var e=l(arguments,1);t.split(/\x20+/).forEach(function(t){if(t in this.events)for(var i=this.events[t],n=0;n0?t.setTimeout(this.play.bind(this),this.delay):this.play()},c.play=function(){this.pause(),this.isAutoplay&&(this.isLooping||this.slideIndex-1?(i=i.split(","),n.X=parseFloat(i[0]),n.Y=parseFloat(i[1])):n.Y=n.X=parseFloat(i),n[this.axis]*=1.001,"scale("+n.X+", "+n.Y+")")}.bind(this)):t.style.webkitTransform+="scale"+this.axis+"(1.001)"},c.originScale=function(t){var e=/([\x20]?scale)([XY]?)\(([^\)]+)\)/;t.style.webkitTransform=t.style.webkitTransform.replace(e,function(t,e,i,n){return t={},i?"1.001"===n?"":(t[i]=parseFloat(n),"scale"+this.axis+"("+(i===this.axis?t[this.axis]/1.001:1)+")"):(n.indexOf(",")>-1?(n=n.split(","),t.X=parseFloat(n[0]),t.Y=parseFloat(n[1])):t.Y=t.X=parseFloat(n),t[this.axis]/=1.001,"scale("+t.X+", "+t.Y+")")}.bind(this))},c._isItself=function(t){var e=this.fixPage;if("string"==typeof e){for(var i,n=[],s=t;!a(s,"islider-outer")&&s!==this.wrap;)n.push(s),s=s.parentNode;if(s=n.pop(),n.length)try{if(i=Array.prototype.slice.call(s.querySelectorAll(e)),i.length)for(var r=0;r-1)return!0}catch(h){return!1}}return!1},c.subjectTo=function(t,e){if(!(!t instanceof d)){var i=this;i.animateTime=t.animateTime,i.isLooping=t.isLooping,i.isAutoplay=!1,t.on("slideStart",function(t){i.startHandler(t)}),t.on("slide",function(t){i.moveHandler(t)}),t.on("slideEnd",function(t){i.endHandler(t)}),t.on("slideChange",function(t){var e=i.data.length,n=i.direction;n>0&&(t-i.slideIndex+e)%e===1?i.slideNext():0>n&&(t-i.slideIndex-e)%e===-1&&i.slidePrev()}),t.on("slideRestore",function(t){i.slideIndex!==t&&i.slideTo(t)})}},"function"==typeof require&&"object"==typeof module&&module&&"object"==typeof exports&&exports?module.exports=d:"function"==typeof define&&define.amd?define(function(){return d}):t.iSlider=t.iSlider||d}(this||window); \ No newline at end of file +!function(t){"use strict";function e(){}function i(t,e){return e.indexOf(t)>-1}function n(t){return"[object Array]"===Object.prototype.toString.call(t)}function s(t){return"[object Object]"===Object.prototype.toString.call(t)}function a(t,e){return t.className.match(new RegExp("(\\s|^)("+e+")(\\s|$)"))}function r(t,e){a(t,e)||(t.className+=" "+e)}function h(t,e){a(t,e)&&(t.className=t.className.replace(RegExp("(\\s|^)("+e+")(\\s|$)"),"$3"))}function o(t){return/<\/?[^>]*>/.test(t)?!1:/^(?:(https|http|ftp|rtsp|mms):)?(\/\/)?(\w+:{0,1}\w*@)?([^\?#:\/]+\.[a-z]+|\d+\.\d+\.\d+\.\d+)?(:[0-9]+)?((?:\.?\/)?([^\?#]*)?(\?[^#]+)?(#.+)?)?$/.test(t)}function l(t){return Array.prototype.slice.apply(t,Array.prototype.slice.call(arguments,1))}var d=function(){var t=l(arguments,0,3);if(!t.length)throw new Error("Parameters required!");var e=s(t.slice(-1)[0])?t.pop():{};switch(t.length){case 2:e.data=e.data||t[1];case 1:e.dom=e.dom||t[0]}if(!e.dom)throw new Error("Container can not be empty!");if(!e.data||!e.data.length)throw new Error("Data must be an array and must have more than one element!");this._opts=e,e=null,t=null,this._setting(),this.fire("initialize"),this._renderWrapper(),this._initPlugins(),this._bindHandler(),this.fire("initialized"),this._autoPlay()};d.VERSION="2.1.4",d.EVENTS=["initialize","initialized","pluginInitialize","pluginInitialized","renderComplete","slide","slideStart","slideEnd","slideChange","slideChanged","slideRestore","slideRestored","loadData","reset","destroy"],d.EASING=[["linear","ease","ease-in","ease-out","ease-in-out"],/cubic-bezier\(([^\d]*(\d+.?\d*)[^\,]*\,?){4}\)/],d.FIX_PAGE_TAGS=["SELECT","INPUT","TEXTAREA","BUTTON","LABEL"],d.NODE_TYPE={unknown:"unknown",empty:"empty",pic:"pic",dom:"dom",html:"html",node:"node",element:"element"},d.TRANSITION_END_EVENT=function(){var t=document.createElement("fakeElement"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(var i in e)if(e.hasOwnProperty(i)&&void 0!==t.style[i])return e[i];return null}(),d.DEVICE_EVENTS=function(){var e=!!("ontouchstart"in t&&!/Mac OS X /.test(t.navigator.userAgent)||t.DocumentTouch&&document instanceof t.DocumentTouch);return{hasTouch:e,startEvt:e?"touchstart":"mousedown",moveEvt:e?"touchmove":"mousemove",endEvt:e?"touchend":"mouseup",cancelEvt:e?"touchcancel":"mouseout",resizeEvt:"onorientationchange"in t?"orientationchange":"resize"}}(),d.extend=function(){var t,e,i=arguments;switch(i.length){case 0:return;case 1:t=d.prototype,e=i[0];break;case 2:t=i[0],e=i[1]}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},d.plugins={},d.regPlugin=function(t,e){d.plugins[t]=d.plugins[t]||e},d._animateFuncs={normal:function(){function t(t,e,i,n,s){t.style.webkitTransform="translateZ(0) translate"+e+"("+(s+i*(n-1))+"px)"}return t.effect="transform",t}()};var c=d.prototype;c.extend=d.extend,c._setting=function(){var s=this;s._plugins=d.plugins,s._animateFuncs=d._animateFuncs,s._holding=!1,s._locking=!1,s._intermediateScene=null,s._transitionEndHandler=null,s._LSN={autoPlay:null,resize:null,transitionEnd:null},s.currentEl=null,s._EventHandle={},s.onMoving=!1,s.onSliding=!1,s.direction=null;var a=this._opts;s.wrap=a.dom,s.data=a.data,s.isVertical=!!a.isVertical,s.isOverspread=!!a.isOverspread,s.duration=a.duration||2e3,s.initIndex=a.initIndex>0&&a.initIndex<=a.data.length-1?a.initIndex:0,s.fixPage=function(){var t=a.fixPage;return t===!1||0===t?!1:n(t)&&t.length>0||"string"==typeof t&&""!==t?[].concat(t).toString():!0}(),s.fillSeam=!!a.fillSeam,s.slideIndex=s.slideIndex||s.initIndex||0,s.axis=s.isVertical?"Y":"X",s.reverseAxis="Y"===s.axis?"X":"Y",s.width="number"==typeof a.width?a.width:s.wrap.offsetWidth,s.height="number"==typeof a.height?a.height:s.wrap.offsetHeight,s.ratio=s.height/s.width,s.scale=s.isVertical?s.height:s.width,s.offset=s.offset||{X:0,Y:0},s.isTouchable=null==a.isTouchable?!0:!!a.isTouchable,s.isLooping=a.isLooping&&s.data.length>1?!0:!1,s.delay=a.delay||0,s.isAutoplay=a.isAutoplay&&s.data.length>1?!0:!1,s.animateType=a.animateType in s._animateFuncs?a.animateType:"normal",s._animateFunc=s._animateFuncs[s.animateType],s._animateReverse=function(){var t=[];for(var e in s._animateFuncs)s._animateFuncs.hasOwnProperty(e)&&s._animateFuncs[e].reverse&&t.push(e);return t}(),s.isVertical&&"card"===s.animateType&&(s.isOverspread=!0),s.log=a.isDebug?function(){t.console.log.apply(t.console,arguments)}:e,s._damping=function(){var t=s.scale>>1,e=t>>1,i=e>>2;return function(n){var s,a=Math.abs(n);return s=t>a?a>>1:t+e>a?e+(a-t>>2):e+i+(a-t-e>>3),n>0?s:-s}}(),s.animateTime=null!=a.animateTime&&a.animateTime>-1?a.animateTime:300,s.animateEasing=i(a.animateEasing,d.EASING[0])||d.EASING[1].test(a.animateEasing)?a.animateEasing:"ease",s.deviceEvents=d.DEVICE_EVENTS,s.fingerRecognitionRange=a.fingerRecognitionRange>-1?parseInt(a.fingerRecognitionRange):10,s.events={},d.EVENTS.forEach(function(t){var e=a["on"+t.toLowerCase()];"function"==typeof e&&s.on(t,e,1)}),s.pluginConfig=function(){var t={};return n(a.plugins)&&a.plugins.forEach(function(e){n(e)?t[e[0]]=e.slice(1):"string"==typeof e&&(t[e]=[])}),t}()},c._initPlugins=function(){var t=this.pluginConfig,e=this._plugins;for(var i in t)t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&e[i]&&"function"==typeof e[i]&&typeof e[i].apply&&e[i].apply(this,t[i]);this.fire("pluginInitialized")},c._itemType=function(t){if(isNaN(t)||(t=this.data[t]),t.hasOwnProperty("type"))return t.type;var e,i=t.content,n=d.NODE_TYPE;return e=null==i?n.empty:Boolean(i.nodeName)&&Boolean(i.nodeType)?n.node:"string"==typeof i?o(i)?n.pic:n.html:n.unknown,t.type=e,e},c._renderItem=function(t,e){var i,n=this,s=this.data.length,a=function(){var e=' src="'+i.content+'"';e+=i.height/i.width>n.ratio?' height="100%"':' width="100%"',n.isOverspread&&(t.style.cssText+="background-image:url("+i.content+");background-repeat:no-repeat;background-position:50% 50%;background-size:cover",e+=' style="display:block;opacity:0;height:100%;width:100%;"'),t.innerHTML=""};if(t.innerHTML="",t.style.background="",this.isLooping||null!=this.data[e]){e=(s+e)%s,i=this.data[e];var r=this._itemType(i),h=d.NODE_TYPE;switch(t.className="islider-"+r,r){case h.pic:if(2===i.load)a();else{var o=new Image;o.src=i.content,o.onload=function(){i.height=o.height,i.width=o.width,a(),i.load=2}}break;case h.dom:case h.html:t.innerHTML=i.content;break;case h.node:case h.element:if(11===i.content.nodeType){var l=document.createElement("div");l.appendChild(i.content),i.content=l}t.appendChild(i.content)}}},c._renderIntermediateScene=function(){null!=this._intermediateScene&&(this._renderItem.apply(this,this._intermediateScene),this._intermediateScene=null)},c._changedStyles=function(){var t=["islider-prev","islider-active","islider-next"];this.els.forEach(function(e,i){h(e,t.join("|")),r(e,t[i]),this.fillSeam&&this.originScale(e)}.bind(this))},c._renderWrapper=function(){var e;this.outer?(e=this.outer,e.innerHTML=""):e=document.createElement("ul"),e.className="islider-outer",this.els=[];for(var i=0;3>i;i++){var n=document.createElement("li");this.els.push(n),this._animateFunc(n,this.axis,this.scale,i,0),this.fixPage||(n.style.overflow="auto"),!this.isVertical||"rotate"!==this.animateType&&"flip"!==this.animateType?this._renderItem(n,i-1+this.slideIndex):this._renderItem(n,1-i+this.slideIndex),e.appendChild(n)}this._changedStyles(),this.fillSeam&&this.els.forEach(function(t,e){r(t,"islider-sliding"+(1===e?"-focus":""))}),t.setTimeout(function(){this._preloadImg(this.slideIndex)}.bind(this),200),this.outer||(this.outer=e,this.wrap.appendChild(e)),this.currentEl=this.els[1],this.fire("renderComplete",this.slideIndex,this.currentEl,this)},c._preloadImg=function(t){if(this.data.length>3){var e=this.data,i=e.length,n=this,s=function(t){var i=e[t];if("pic"===n._itemType(i)&&!i.load){var s=new Image;s.src=i.content,s.onload=function(){i.width=s.width,i.height=s.height,i.load=2},i.load=1}};s((t+2)%i),s((t-2+i)%i)}},c._watchTransitionEnd=function(e,i){this._unWatchTransitionEnd();var n=function(){this._unWatchTransitionEnd(),"slideChanged"===i&&this._changedStyles(),this.fire.call(this,i,this.slideIndex,this.currentEl,this),this._renderIntermediateScene(),this.play(),this.onSliding=!1,this.direction=null}.bind(this);d.TRANSITION_END_EVENT?(this.currentEl.addEventListener(d.TRANSITION_END_EVENT,n),this._transitionEndHandler={el:this.currentEl,handler:n}):this._LSN.transitionEnd=t.setTimeout(n,e)},c._unWatchTransitionEnd=function(){this._LSN.transitionEnd&&t.clearTimeout(this._LSN.transitionEnd),null!==this._transitionEndHandler&&(this._transitionEndHandler.el.removeEventListener(d.TRANSITION_END_EVENT,this._transitionEndHandler.handler),this._transitionEndHandler=null)},c._bindHandler=function(){var e=this.outer,i=this.deviceEvents;this.isTouchable&&(i.hasTouch||(e.style.cursor="pointer",e.ondragstart=function(t){return t?!1:!0}),e.addEventListener(i.startEvt,this),e.addEventListener(i.moveEvt,this),e.addEventListener(i.endEvt,this),!i.hasTouch&&e.addEventListener("mouseout",this)),t.addEventListener(i.resizeEvt,this),t.addEventListener("focus",this,!1),t.addEventListener("blur",this,!1)},c.handleEvent=function(t){var e=this.deviceEvents;switch(t.type){case"mousedown":if(0!==t.button)break;case"touchstart":this.startHandler(t);break;case e.moveEvt:this.moveHandler(t);break;case e.endEvt:case e.cancelEvt:this.endHandler(t);break;case e.resizeEvt:this.resizeHandler();break;case"focus":this.play();break;case"blur":this.pause()}},c.startHandler=function(t){if(this.fixPage&&d.FIX_PAGE_TAGS.indexOf(t.target.tagName.toUpperCase())<0&&!this._isItself(t.target)&&t.preventDefault(),!this._holding&&!this._locking){var e=this.deviceEvents;this.onMoving=!0,this.pause(),this.fire("slideStart",t,this),this.startTime=(new Date).getTime(),this.startX=e.hasTouch?t.targetTouches[0].pageX:t.pageX,this.startY=e.hasTouch?t.targetTouches[0].pageY:t.pageY}},c.moveHandler=function(t){if(this.onMoving){var e=this.deviceEvents,i=this.data.length,n=this.axis,s=this.reverseAxis,a={};t.hasOwnProperty("offsetRatio")?(a[n]=t.offsetRatio*this.scale,a[s]=0):(a.X=e.hasTouch?t.targetTouches[0].pageX-this.startX:t.pageX-this.startX,a.Y=e.hasTouch?t.targetTouches[0].pageY-this.startY:t.pageY-this.startY),this.offset=a,t.offsetRatio=a[n]/this.scale,Math.abs(a[n])-Math.abs(a[s])>10&&(t.preventDefault(),this._unWatchTransitionEnd(),this.isLooping||(a[n]>0&&0===this.slideIndex||a[n]<0&&this.slideIndex===i-1)&&(a[n]=this._damping(a[n])),this.els.forEach(function(t,e){t.style.visibility="visible",t.style.webkitTransition="none",this._animateFunc(t,n,this.scale,e,a[n],a[n]),this.fillSeam&&this.seamScale(t)}.bind(this)),this.fire("slide",t,this))}},c.endHandler=function(e){function i(n){if(null!=n)if("A"===n.tagName){if(n.href)return"_blank"===n.getAttribute("target")?t.open(n.href):t.location.href=n.href,e.preventDefault(),!1}else{if("LI"===n.tagName&&n.className.search(/^islider\-/)>-1)return!1;i(n.parentNode)}}if(this.onMoving){this.onMoving=!1;var n=this.offset,s=this.axis,a=this.scale/2,r=(new Date).getTime(),h=this.fingerRecognitionRange;a=r-this.startTime>300?a:14;var o=Math.abs(n[s]),l=Math.abs(n[this.reverseAxis]);this.fire("slideEnd",e,this),n[s]>=a&&o>l?this.slideTo(this.slideIndex-1):n[s]<-a&&o>l?this.slideTo(this.slideIndex+1):Math.abs(this.offset[s])>=h&&this.slideTo(this.slideIndex),Math.abs(this.offset[s])=1e3&&n&&t.clearInterval(n)}.bind(this),12)):(n&&t.clearTimeout(n),n=t.setTimeout(function(){(this.height!==this.wrap.offsetHeight||this.width!==this.wrap.offsetWidth)&&(n&&t.clearInterval(n),this.reset())}.bind(this),200))},c.slideTo=function(t,e){if(this.isAutoplay&&this.pause(),!this._locking){this.unhold(),this.onSliding=!0;var n,s=this.animateTime,a=this.animateType,o=this._animateFunc,l=this.data,d=this.els,c=this.axis,u=t,f=t-this.slideIndex,p=this.offset,g=0;"object"==typeof e&&(e.animateTime>-1&&(s=e.animateTime),"string"==typeof e.animateType&&e.animateType in this._animateFuncs&&(a=e.animateType,o=this._animateFuncs[a])),0!==p[c]&&(g=Math.abs(p[c])/this.scale*s),Math.abs(f)>1&&this._renderItem(f>0?this.els[2]:this.els[0],u),this._preloadImg(u),l[u]?this.slideIndex=u:this.isLooping?this.slideIndex=f>0?0:l.length-1:f=0;var m,v,E;0===f?n="slideRestore":((this.isVertical&&i(a,this._animateReverse))^f>0?(d.push(d.shift()),m=d[2],v=d[0],E=1):(d.unshift(d.pop()),m=d[0],v=d[2],E=-1),this.currentEl=d[1],1===Math.abs(f)?(this._renderIntermediateScene(),this._renderItem(m,u+f)):Math.abs(f)>1&&(this._renderItem(m,u+E),this._intermediateScene=[v,u-E]),m.style.webkitTransition="none",g=s-g,n="slideChange",this.fillSeam&&(d.forEach(function(t){h(t,"islider-sliding|islider-sliding-focus")}),r(this.currentEl,"islider-sliding-focus"),r(m,"islider-sliding")),this.direction=E);for(var _=0;3>_;_++)d[_]!==m&&(d[_].style.webkitTransition=(o.effect||"all")+" "+g+"ms "+this.animateEasing),o.call(this,d[_],c,this.scale,_,0,E),this.fillSeam&&this.seamScale(d[_]);this._watchTransitionEnd(g,n+"d"),this.fire(n,this.slideIndex,this.currentEl,this)}},c.slideNext=function(){this.slideTo.apply(this,[this.slideIndex+1].concat(l(arguments)))},c.slidePrev=function(){this.slideTo.apply(this,[this.slideIndex-1].concat(l(arguments)))},c.regPlugin=function(){var t=l(arguments),e=t.shift(),n=t[0];(this._plugins.hasOwnProperty(e)||"function"==typeof n)&&("function"==typeof n&&(this._plugins[e]=n,t.shift()),i(e,this._opts.plugins)||(this._opts.plugins.push(t.length?[].concat([e],t):e),"function"==typeof this._plugins[e]&&this._plugins[e].apply(this,t)))},c.bind=c.delegate=function(e,i,n){function s(e){for(var s=t.event?t.event:e,a=s.target,r=document.querySelectorAll(i),h=0;h-1)return this.wrap.removeEventListener(t,this._EventHandle[n][1][s]),this._EventHandle[n][0][s]=this._EventHandle[n][1][s]=null,!0}return!1},c.destroy=function(){var e=this.outer,i=this.deviceEvents;this.fire("destroy"),this.isTouchable&&(e.removeEventListener(i.startEvt,this),e.removeEventListener(i.moveEvt,this),e.removeEventListener(i.endEvt,this),!i.hasTouch&&e.removeEventListener("mouseout",this)),t.removeEventListener(i.resizeEvt,this),t.removeEventListener("focus",this),t.removeEventListener("blur",this);var n;for(n in this._EventHandle)for(var s=this._EventHandle[n][1],a=0;a-1&&delete this.events[t][i]}},c.fire=function(t){var e=l(arguments,1);t.split(/\x20+/).forEach(function(t){if(t in this.events)for(var i=this.events[t],n=0;n0?t.setTimeout(this.play.bind(this),this.delay):this.play()},c.play=function(){this.pause(),this.isAutoplay&&(this.isLooping||this.slideIndex-1?(i=i.split(","),n.X=parseFloat(i[0]),n.Y=parseFloat(i[1])):n.Y=n.X=parseFloat(i),n[this.axis]*=1.001,"scale("+n.X+", "+n.Y+")")}.bind(this)):t.style.webkitTransform+="scale"+this.axis+"(1.001)"},c.originScale=function(t){var e=/([\x20]?scale)([XY]?)\(([^\)]+)\)/;t.style.webkitTransform=t.style.webkitTransform.replace(e,function(t,e,i,n){return t={},i?"1.001"===n?"":(t[i]=parseFloat(n),"scale"+this.axis+"("+(i===this.axis?t[this.axis]/1.001:1)+")"):(n.indexOf(",")>-1?(n=n.split(","),t.X=parseFloat(n[0]),t.Y=parseFloat(n[1])):t.Y=t.X=parseFloat(n),t[this.axis]/=1.001,"scale("+t.X+", "+t.Y+")")}.bind(this))},c._isItself=function(t){var e=this.fixPage;if("string"==typeof e){for(var i,n=[],s=t;!a(s,"islider-outer")&&s!==this.wrap;)n.push(s),s=s.parentNode;if(s=n.pop(),n.length)try{if(i=Array.prototype.slice.call(s.querySelectorAll(e)),i.length)for(var r=0;r-1)return!0}catch(h){return!1}}return!1},c.subjectTo=function(t,e){if(!(!t instanceof d)){var i=this;i.animateTime=t.animateTime,i.isLooping=t.isLooping,i.isAutoplay=!1,t.on("slideStart",function(t){i.startHandler(t)}),t.on("slide",function(t){i.moveHandler(t)}),t.on("slideEnd",function(t){i.endHandler(t)}),t.on("slideChange",function(t){var e=i.data.length,n=i.direction;n>0&&(t-i.slideIndex+e)%e===1?i.slideNext():0>n&&(t-i.slideIndex-e)%e===-1&&i.slidePrev()}),t.on("slideRestore",function(t){i.slideIndex!==t&&i.slideTo(t)})}},"function"==typeof require&&"object"==typeof module&&module&&"object"==typeof exports&&exports?module.exports=d:"function"==typeof define&&define.amd?define(function(){return d}):t.iSlider=t.iSlider||d}(this||window); \ No newline at end of file diff --git a/demo/add_dynamic_data.html b/demo/add_dynamic_data.html new file mode 100644 index 00000000..23e41527 --- /dev/null +++ b/demo/add_dynamic_data.html @@ -0,0 +1,74 @@ + + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/demo/public/js/iSlider.js b/demo/public/js/iSlider.js index 58ca207b..5d29863c 100644 --- a/demo/public/js/iSlider.js +++ b/demo/public/js/iSlider.js @@ -1690,6 +1690,27 @@ this.fire('loadData slideChanged', this.slideIndex, this.currentEl, this); }; + /** + * Add dynamic data + * + * @param {Object|Array} sceneData + * @description + * Object: + * {content:...} + * Array: + * [{content:...}, {content:...}, ...] + */ + iSliderPrototype.addData = function (sceneData) { + var len = this.data.length; + this.data = this.data.concat(sceneData); + console.log('addData', len - 1 === this.slideIndex); + if (this.isLooping && this.slideIndex === 0) { + this._renderItem(this.els[0], this.data.length - 1); + } else if (len - 1 === this.slideIndex) { + this._renderItem(this.els[2], len); + } + }; + /** * auto check to play and bind events * @private diff --git a/src/js/iSlider.js b/src/js/iSlider.js index 58ca207b..5d29863c 100644 --- a/src/js/iSlider.js +++ b/src/js/iSlider.js @@ -1690,6 +1690,27 @@ this.fire('loadData slideChanged', this.slideIndex, this.currentEl, this); }; + /** + * Add dynamic data + * + * @param {Object|Array} sceneData + * @description + * Object: + * {content:...} + * Array: + * [{content:...}, {content:...}, ...] + */ + iSliderPrototype.addData = function (sceneData) { + var len = this.data.length; + this.data = this.data.concat(sceneData); + console.log('addData', len - 1 === this.slideIndex); + if (this.isLooping && this.slideIndex === 0) { + this._renderItem(this.els[0], this.data.length - 1); + } else if (len - 1 === this.slideIndex) { + this._renderItem(this.els[2], len); + } + }; + /** * auto check to play and bind events * @private From 5dba2eb7975ab20f683a0c03124f25048dcd8da7 Mon Sep 17 00:00:00 2001 From: shinate Date: Thu, 17 Mar 2016 15:17:25 +0800 Subject: [PATCH 2/9] addDate rename to pushData --- README.md | 10 +++++++++- README_Chinese.md | 7 +++++++ build/iSlider.js | 9 ++++++--- build/iSlider.min.js | 2 +- demo/public/js/iSlider.js | 9 ++++++--- src/js/iSlider.js | 11 +++++++---- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5de54c4e..2b085ae2 100644 --- a/README.md +++ b/README.md @@ -665,7 +665,7 @@ S.on('slideChanged', callBack); #### regPlugin - Same as the static method "regPlugin" -- ** This method will be registered the plug-in into the iSlider instance,It will add an active list of plug-in automatically when registeration and performs initialization automatically.** +- ** This method will be registered the plug-in into the iSlider instance, It will add an active list of plug-in automatically when registeration and performs initialization automatically.** #### loadData @@ -673,6 +673,14 @@ S.on('slideChanged', callBack); - Loading new Datasheets - Parameters: - `{Array}` Datasheets + - `{Number}` Index, default: 0 + + +#### pushData + +- Add scenes to the end of the data datasheets +- Parameters: + - `{Array|Object}` A member or additional datasheets #### subjectTo diff --git a/README_Chinese.md b/README_Chinese.md index 01c9512d..747fb231 100644 --- a/README_Chinese.md +++ b/README_Chinese.md @@ -675,6 +675,13 @@ S.on('slideChanged', callBack); - `{Array}` 数据列表 +#### pushData + +- 追加数据到已有的数据序列末尾 +- 参数: + - `{Array|Object}` 一个成员或者追加的序列(数组) + + #### subjectTo - 服从于另一个iSlider实例 diff --git a/build/iSlider.js b/build/iSlider.js index 5d29863c..dd876646 100644 --- a/build/iSlider.js +++ b/build/iSlider.js @@ -1677,7 +1677,10 @@ }; /** - * reload Data & render + * Reload Data & render + * + * @param {Array} data + * @param {Number} initIndex * @public */ iSliderPrototype.loadData = function (data, initIndex) { @@ -1691,7 +1694,7 @@ }; /** - * Add dynamic data + * Additional members to the end of the data sequence * * @param {Object|Array} sceneData * @description @@ -1703,11 +1706,11 @@ iSliderPrototype.addData = function (sceneData) { var len = this.data.length; this.data = this.data.concat(sceneData); - console.log('addData', len - 1 === this.slideIndex); if (this.isLooping && this.slideIndex === 0) { this._renderItem(this.els[0], this.data.length - 1); } else if (len - 1 === this.slideIndex) { this._renderItem(this.els[2], len); + this._autoPlay(); // restart } }; diff --git a/build/iSlider.min.js b/build/iSlider.min.js index 31bd2d0c..eaf3f00a 100644 --- a/build/iSlider.min.js +++ b/build/iSlider.min.js @@ -1 +1 @@ -!function(t){"use strict";function e(){}function i(t,e){return e.indexOf(t)>-1}function n(t){return"[object Array]"===Object.prototype.toString.call(t)}function s(t){return"[object Object]"===Object.prototype.toString.call(t)}function a(t,e){return t.className.match(new RegExp("(\\s|^)("+e+")(\\s|$)"))}function r(t,e){a(t,e)||(t.className+=" "+e)}function h(t,e){a(t,e)&&(t.className=t.className.replace(RegExp("(\\s|^)("+e+")(\\s|$)"),"$3"))}function o(t){return/<\/?[^>]*>/.test(t)?!1:/^(?:(https|http|ftp|rtsp|mms):)?(\/\/)?(\w+:{0,1}\w*@)?([^\?#:\/]+\.[a-z]+|\d+\.\d+\.\d+\.\d+)?(:[0-9]+)?((?:\.?\/)?([^\?#]*)?(\?[^#]+)?(#.+)?)?$/.test(t)}function l(t){return Array.prototype.slice.apply(t,Array.prototype.slice.call(arguments,1))}var d=function(){var t=l(arguments,0,3);if(!t.length)throw new Error("Parameters required!");var e=s(t.slice(-1)[0])?t.pop():{};switch(t.length){case 2:e.data=e.data||t[1];case 1:e.dom=e.dom||t[0]}if(!e.dom)throw new Error("Container can not be empty!");if(!e.data||!e.data.length)throw new Error("Data must be an array and must have more than one element!");this._opts=e,e=null,t=null,this._setting(),this.fire("initialize"),this._renderWrapper(),this._initPlugins(),this._bindHandler(),this.fire("initialized"),this._autoPlay()};d.VERSION="2.1.4",d.EVENTS=["initialize","initialized","pluginInitialize","pluginInitialized","renderComplete","slide","slideStart","slideEnd","slideChange","slideChanged","slideRestore","slideRestored","loadData","reset","destroy"],d.EASING=[["linear","ease","ease-in","ease-out","ease-in-out"],/cubic-bezier\(([^\d]*(\d+.?\d*)[^\,]*\,?){4}\)/],d.FIX_PAGE_TAGS=["SELECT","INPUT","TEXTAREA","BUTTON","LABEL"],d.NODE_TYPE={unknown:"unknown",empty:"empty",pic:"pic",dom:"dom",html:"html",node:"node",element:"element"},d.TRANSITION_END_EVENT=function(){var t=document.createElement("fakeElement"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(var i in e)if(e.hasOwnProperty(i)&&void 0!==t.style[i])return e[i];return null}(),d.DEVICE_EVENTS=function(){var e=!!("ontouchstart"in t&&!/Mac OS X /.test(t.navigator.userAgent)||t.DocumentTouch&&document instanceof t.DocumentTouch);return{hasTouch:e,startEvt:e?"touchstart":"mousedown",moveEvt:e?"touchmove":"mousemove",endEvt:e?"touchend":"mouseup",cancelEvt:e?"touchcancel":"mouseout",resizeEvt:"onorientationchange"in t?"orientationchange":"resize"}}(),d.extend=function(){var t,e,i=arguments;switch(i.length){case 0:return;case 1:t=d.prototype,e=i[0];break;case 2:t=i[0],e=i[1]}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},d.plugins={},d.regPlugin=function(t,e){d.plugins[t]=d.plugins[t]||e},d._animateFuncs={normal:function(){function t(t,e,i,n,s){t.style.webkitTransform="translateZ(0) translate"+e+"("+(s+i*(n-1))+"px)"}return t.effect="transform",t}()};var c=d.prototype;c.extend=d.extend,c._setting=function(){var s=this;s._plugins=d.plugins,s._animateFuncs=d._animateFuncs,s._holding=!1,s._locking=!1,s._intermediateScene=null,s._transitionEndHandler=null,s._LSN={autoPlay:null,resize:null,transitionEnd:null},s.currentEl=null,s._EventHandle={},s.onMoving=!1,s.onSliding=!1,s.direction=null;var a=this._opts;s.wrap=a.dom,s.data=a.data,s.isVertical=!!a.isVertical,s.isOverspread=!!a.isOverspread,s.duration=a.duration||2e3,s.initIndex=a.initIndex>0&&a.initIndex<=a.data.length-1?a.initIndex:0,s.fixPage=function(){var t=a.fixPage;return t===!1||0===t?!1:n(t)&&t.length>0||"string"==typeof t&&""!==t?[].concat(t).toString():!0}(),s.fillSeam=!!a.fillSeam,s.slideIndex=s.slideIndex||s.initIndex||0,s.axis=s.isVertical?"Y":"X",s.reverseAxis="Y"===s.axis?"X":"Y",s.width="number"==typeof a.width?a.width:s.wrap.offsetWidth,s.height="number"==typeof a.height?a.height:s.wrap.offsetHeight,s.ratio=s.height/s.width,s.scale=s.isVertical?s.height:s.width,s.offset=s.offset||{X:0,Y:0},s.isTouchable=null==a.isTouchable?!0:!!a.isTouchable,s.isLooping=a.isLooping&&s.data.length>1?!0:!1,s.delay=a.delay||0,s.isAutoplay=a.isAutoplay&&s.data.length>1?!0:!1,s.animateType=a.animateType in s._animateFuncs?a.animateType:"normal",s._animateFunc=s._animateFuncs[s.animateType],s._animateReverse=function(){var t=[];for(var e in s._animateFuncs)s._animateFuncs.hasOwnProperty(e)&&s._animateFuncs[e].reverse&&t.push(e);return t}(),s.isVertical&&"card"===s.animateType&&(s.isOverspread=!0),s.log=a.isDebug?function(){t.console.log.apply(t.console,arguments)}:e,s._damping=function(){var t=s.scale>>1,e=t>>1,i=e>>2;return function(n){var s,a=Math.abs(n);return s=t>a?a>>1:t+e>a?e+(a-t>>2):e+i+(a-t-e>>3),n>0?s:-s}}(),s.animateTime=null!=a.animateTime&&a.animateTime>-1?a.animateTime:300,s.animateEasing=i(a.animateEasing,d.EASING[0])||d.EASING[1].test(a.animateEasing)?a.animateEasing:"ease",s.deviceEvents=d.DEVICE_EVENTS,s.fingerRecognitionRange=a.fingerRecognitionRange>-1?parseInt(a.fingerRecognitionRange):10,s.events={},d.EVENTS.forEach(function(t){var e=a["on"+t.toLowerCase()];"function"==typeof e&&s.on(t,e,1)}),s.pluginConfig=function(){var t={};return n(a.plugins)&&a.plugins.forEach(function(e){n(e)?t[e[0]]=e.slice(1):"string"==typeof e&&(t[e]=[])}),t}()},c._initPlugins=function(){var t=this.pluginConfig,e=this._plugins;for(var i in t)t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&e[i]&&"function"==typeof e[i]&&typeof e[i].apply&&e[i].apply(this,t[i]);this.fire("pluginInitialized")},c._itemType=function(t){if(isNaN(t)||(t=this.data[t]),t.hasOwnProperty("type"))return t.type;var e,i=t.content,n=d.NODE_TYPE;return e=null==i?n.empty:Boolean(i.nodeName)&&Boolean(i.nodeType)?n.node:"string"==typeof i?o(i)?n.pic:n.html:n.unknown,t.type=e,e},c._renderItem=function(t,e){var i,n=this,s=this.data.length,a=function(){var e=' src="'+i.content+'"';e+=i.height/i.width>n.ratio?' height="100%"':' width="100%"',n.isOverspread&&(t.style.cssText+="background-image:url("+i.content+");background-repeat:no-repeat;background-position:50% 50%;background-size:cover",e+=' style="display:block;opacity:0;height:100%;width:100%;"'),t.innerHTML=""};if(t.innerHTML="",t.style.background="",this.isLooping||null!=this.data[e]){e=(s+e)%s,i=this.data[e];var r=this._itemType(i),h=d.NODE_TYPE;switch(t.className="islider-"+r,r){case h.pic:if(2===i.load)a();else{var o=new Image;o.src=i.content,o.onload=function(){i.height=o.height,i.width=o.width,a(),i.load=2}}break;case h.dom:case h.html:t.innerHTML=i.content;break;case h.node:case h.element:if(11===i.content.nodeType){var l=document.createElement("div");l.appendChild(i.content),i.content=l}t.appendChild(i.content)}}},c._renderIntermediateScene=function(){null!=this._intermediateScene&&(this._renderItem.apply(this,this._intermediateScene),this._intermediateScene=null)},c._changedStyles=function(){var t=["islider-prev","islider-active","islider-next"];this.els.forEach(function(e,i){h(e,t.join("|")),r(e,t[i]),this.fillSeam&&this.originScale(e)}.bind(this))},c._renderWrapper=function(){var e;this.outer?(e=this.outer,e.innerHTML=""):e=document.createElement("ul"),e.className="islider-outer",this.els=[];for(var i=0;3>i;i++){var n=document.createElement("li");this.els.push(n),this._animateFunc(n,this.axis,this.scale,i,0),this.fixPage||(n.style.overflow="auto"),!this.isVertical||"rotate"!==this.animateType&&"flip"!==this.animateType?this._renderItem(n,i-1+this.slideIndex):this._renderItem(n,1-i+this.slideIndex),e.appendChild(n)}this._changedStyles(),this.fillSeam&&this.els.forEach(function(t,e){r(t,"islider-sliding"+(1===e?"-focus":""))}),t.setTimeout(function(){this._preloadImg(this.slideIndex)}.bind(this),200),this.outer||(this.outer=e,this.wrap.appendChild(e)),this.currentEl=this.els[1],this.fire("renderComplete",this.slideIndex,this.currentEl,this)},c._preloadImg=function(t){if(this.data.length>3){var e=this.data,i=e.length,n=this,s=function(t){var i=e[t];if("pic"===n._itemType(i)&&!i.load){var s=new Image;s.src=i.content,s.onload=function(){i.width=s.width,i.height=s.height,i.load=2},i.load=1}};s((t+2)%i),s((t-2+i)%i)}},c._watchTransitionEnd=function(e,i){this._unWatchTransitionEnd();var n=function(){this._unWatchTransitionEnd(),"slideChanged"===i&&this._changedStyles(),this.fire.call(this,i,this.slideIndex,this.currentEl,this),this._renderIntermediateScene(),this.play(),this.onSliding=!1,this.direction=null}.bind(this);d.TRANSITION_END_EVENT?(this.currentEl.addEventListener(d.TRANSITION_END_EVENT,n),this._transitionEndHandler={el:this.currentEl,handler:n}):this._LSN.transitionEnd=t.setTimeout(n,e)},c._unWatchTransitionEnd=function(){this._LSN.transitionEnd&&t.clearTimeout(this._LSN.transitionEnd),null!==this._transitionEndHandler&&(this._transitionEndHandler.el.removeEventListener(d.TRANSITION_END_EVENT,this._transitionEndHandler.handler),this._transitionEndHandler=null)},c._bindHandler=function(){var e=this.outer,i=this.deviceEvents;this.isTouchable&&(i.hasTouch||(e.style.cursor="pointer",e.ondragstart=function(t){return t?!1:!0}),e.addEventListener(i.startEvt,this),e.addEventListener(i.moveEvt,this),e.addEventListener(i.endEvt,this),!i.hasTouch&&e.addEventListener("mouseout",this)),t.addEventListener(i.resizeEvt,this),t.addEventListener("focus",this,!1),t.addEventListener("blur",this,!1)},c.handleEvent=function(t){var e=this.deviceEvents;switch(t.type){case"mousedown":if(0!==t.button)break;case"touchstart":this.startHandler(t);break;case e.moveEvt:this.moveHandler(t);break;case e.endEvt:case e.cancelEvt:this.endHandler(t);break;case e.resizeEvt:this.resizeHandler();break;case"focus":this.play();break;case"blur":this.pause()}},c.startHandler=function(t){if(this.fixPage&&d.FIX_PAGE_TAGS.indexOf(t.target.tagName.toUpperCase())<0&&!this._isItself(t.target)&&t.preventDefault(),!this._holding&&!this._locking){var e=this.deviceEvents;this.onMoving=!0,this.pause(),this.fire("slideStart",t,this),this.startTime=(new Date).getTime(),this.startX=e.hasTouch?t.targetTouches[0].pageX:t.pageX,this.startY=e.hasTouch?t.targetTouches[0].pageY:t.pageY}},c.moveHandler=function(t){if(this.onMoving){var e=this.deviceEvents,i=this.data.length,n=this.axis,s=this.reverseAxis,a={};t.hasOwnProperty("offsetRatio")?(a[n]=t.offsetRatio*this.scale,a[s]=0):(a.X=e.hasTouch?t.targetTouches[0].pageX-this.startX:t.pageX-this.startX,a.Y=e.hasTouch?t.targetTouches[0].pageY-this.startY:t.pageY-this.startY),this.offset=a,t.offsetRatio=a[n]/this.scale,Math.abs(a[n])-Math.abs(a[s])>10&&(t.preventDefault(),this._unWatchTransitionEnd(),this.isLooping||(a[n]>0&&0===this.slideIndex||a[n]<0&&this.slideIndex===i-1)&&(a[n]=this._damping(a[n])),this.els.forEach(function(t,e){t.style.visibility="visible",t.style.webkitTransition="none",this._animateFunc(t,n,this.scale,e,a[n],a[n]),this.fillSeam&&this.seamScale(t)}.bind(this)),this.fire("slide",t,this))}},c.endHandler=function(e){function i(n){if(null!=n)if("A"===n.tagName){if(n.href)return"_blank"===n.getAttribute("target")?t.open(n.href):t.location.href=n.href,e.preventDefault(),!1}else{if("LI"===n.tagName&&n.className.search(/^islider\-/)>-1)return!1;i(n.parentNode)}}if(this.onMoving){this.onMoving=!1;var n=this.offset,s=this.axis,a=this.scale/2,r=(new Date).getTime(),h=this.fingerRecognitionRange;a=r-this.startTime>300?a:14;var o=Math.abs(n[s]),l=Math.abs(n[this.reverseAxis]);this.fire("slideEnd",e,this),n[s]>=a&&o>l?this.slideTo(this.slideIndex-1):n[s]<-a&&o>l?this.slideTo(this.slideIndex+1):Math.abs(this.offset[s])>=h&&this.slideTo(this.slideIndex),Math.abs(this.offset[s])=1e3&&n&&t.clearInterval(n)}.bind(this),12)):(n&&t.clearTimeout(n),n=t.setTimeout(function(){(this.height!==this.wrap.offsetHeight||this.width!==this.wrap.offsetWidth)&&(n&&t.clearInterval(n),this.reset())}.bind(this),200))},c.slideTo=function(t,e){if(this.isAutoplay&&this.pause(),!this._locking){this.unhold(),this.onSliding=!0;var n,s=this.animateTime,a=this.animateType,o=this._animateFunc,l=this.data,d=this.els,c=this.axis,u=t,f=t-this.slideIndex,p=this.offset,g=0;"object"==typeof e&&(e.animateTime>-1&&(s=e.animateTime),"string"==typeof e.animateType&&e.animateType in this._animateFuncs&&(a=e.animateType,o=this._animateFuncs[a])),0!==p[c]&&(g=Math.abs(p[c])/this.scale*s),Math.abs(f)>1&&this._renderItem(f>0?this.els[2]:this.els[0],u),this._preloadImg(u),l[u]?this.slideIndex=u:this.isLooping?this.slideIndex=f>0?0:l.length-1:f=0;var m,v,E;0===f?n="slideRestore":((this.isVertical&&i(a,this._animateReverse))^f>0?(d.push(d.shift()),m=d[2],v=d[0],E=1):(d.unshift(d.pop()),m=d[0],v=d[2],E=-1),this.currentEl=d[1],1===Math.abs(f)?(this._renderIntermediateScene(),this._renderItem(m,u+f)):Math.abs(f)>1&&(this._renderItem(m,u+E),this._intermediateScene=[v,u-E]),m.style.webkitTransition="none",g=s-g,n="slideChange",this.fillSeam&&(d.forEach(function(t){h(t,"islider-sliding|islider-sliding-focus")}),r(this.currentEl,"islider-sliding-focus"),r(m,"islider-sliding")),this.direction=E);for(var _=0;3>_;_++)d[_]!==m&&(d[_].style.webkitTransition=(o.effect||"all")+" "+g+"ms "+this.animateEasing),o.call(this,d[_],c,this.scale,_,0,E),this.fillSeam&&this.seamScale(d[_]);this._watchTransitionEnd(g,n+"d"),this.fire(n,this.slideIndex,this.currentEl,this)}},c.slideNext=function(){this.slideTo.apply(this,[this.slideIndex+1].concat(l(arguments)))},c.slidePrev=function(){this.slideTo.apply(this,[this.slideIndex-1].concat(l(arguments)))},c.regPlugin=function(){var t=l(arguments),e=t.shift(),n=t[0];(this._plugins.hasOwnProperty(e)||"function"==typeof n)&&("function"==typeof n&&(this._plugins[e]=n,t.shift()),i(e,this._opts.plugins)||(this._opts.plugins.push(t.length?[].concat([e],t):e),"function"==typeof this._plugins[e]&&this._plugins[e].apply(this,t)))},c.bind=c.delegate=function(e,i,n){function s(e){for(var s=t.event?t.event:e,a=s.target,r=document.querySelectorAll(i),h=0;h-1)return this.wrap.removeEventListener(t,this._EventHandle[n][1][s]),this._EventHandle[n][0][s]=this._EventHandle[n][1][s]=null,!0}return!1},c.destroy=function(){var e=this.outer,i=this.deviceEvents;this.fire("destroy"),this.isTouchable&&(e.removeEventListener(i.startEvt,this),e.removeEventListener(i.moveEvt,this),e.removeEventListener(i.endEvt,this),!i.hasTouch&&e.removeEventListener("mouseout",this)),t.removeEventListener(i.resizeEvt,this),t.removeEventListener("focus",this),t.removeEventListener("blur",this);var n;for(n in this._EventHandle)for(var s=this._EventHandle[n][1],a=0;a-1&&delete this.events[t][i]}},c.fire=function(t){var e=l(arguments,1);t.split(/\x20+/).forEach(function(t){if(t in this.events)for(var i=this.events[t],n=0;n0?t.setTimeout(this.play.bind(this),this.delay):this.play()},c.play=function(){this.pause(),this.isAutoplay&&(this.isLooping||this.slideIndex-1?(i=i.split(","),n.X=parseFloat(i[0]),n.Y=parseFloat(i[1])):n.Y=n.X=parseFloat(i),n[this.axis]*=1.001,"scale("+n.X+", "+n.Y+")")}.bind(this)):t.style.webkitTransform+="scale"+this.axis+"(1.001)"},c.originScale=function(t){var e=/([\x20]?scale)([XY]?)\(([^\)]+)\)/;t.style.webkitTransform=t.style.webkitTransform.replace(e,function(t,e,i,n){return t={},i?"1.001"===n?"":(t[i]=parseFloat(n),"scale"+this.axis+"("+(i===this.axis?t[this.axis]/1.001:1)+")"):(n.indexOf(",")>-1?(n=n.split(","),t.X=parseFloat(n[0]),t.Y=parseFloat(n[1])):t.Y=t.X=parseFloat(n),t[this.axis]/=1.001,"scale("+t.X+", "+t.Y+")")}.bind(this))},c._isItself=function(t){var e=this.fixPage;if("string"==typeof e){for(var i,n=[],s=t;!a(s,"islider-outer")&&s!==this.wrap;)n.push(s),s=s.parentNode;if(s=n.pop(),n.length)try{if(i=Array.prototype.slice.call(s.querySelectorAll(e)),i.length)for(var r=0;r-1)return!0}catch(h){return!1}}return!1},c.subjectTo=function(t,e){if(!(!t instanceof d)){var i=this;i.animateTime=t.animateTime,i.isLooping=t.isLooping,i.isAutoplay=!1,t.on("slideStart",function(t){i.startHandler(t)}),t.on("slide",function(t){i.moveHandler(t)}),t.on("slideEnd",function(t){i.endHandler(t)}),t.on("slideChange",function(t){var e=i.data.length,n=i.direction;n>0&&(t-i.slideIndex+e)%e===1?i.slideNext():0>n&&(t-i.slideIndex-e)%e===-1&&i.slidePrev()}),t.on("slideRestore",function(t){i.slideIndex!==t&&i.slideTo(t)})}},"function"==typeof require&&"object"==typeof module&&module&&"object"==typeof exports&&exports?module.exports=d:"function"==typeof define&&define.amd?define(function(){return d}):t.iSlider=t.iSlider||d}(this||window); \ No newline at end of file +!function(t){"use strict";function e(){}function i(t,e){return e.indexOf(t)>-1}function n(t){return"[object Array]"===Object.prototype.toString.call(t)}function s(t){return"[object Object]"===Object.prototype.toString.call(t)}function a(t,e){return t.className.match(new RegExp("(\\s|^)("+e+")(\\s|$)"))}function r(t,e){a(t,e)||(t.className+=" "+e)}function h(t,e){a(t,e)&&(t.className=t.className.replace(RegExp("(\\s|^)("+e+")(\\s|$)"),"$3"))}function o(t){return/<\/?[^>]*>/.test(t)?!1:/^(?:(https|http|ftp|rtsp|mms):)?(\/\/)?(\w+:{0,1}\w*@)?([^\?#:\/]+\.[a-z]+|\d+\.\d+\.\d+\.\d+)?(:[0-9]+)?((?:\.?\/)?([^\?#]*)?(\?[^#]+)?(#.+)?)?$/.test(t)}function l(t){return Array.prototype.slice.apply(t,Array.prototype.slice.call(arguments,1))}var d=function(){var t=l(arguments,0,3);if(!t.length)throw new Error("Parameters required!");var e=s(t.slice(-1)[0])?t.pop():{};switch(t.length){case 2:e.data=e.data||t[1];case 1:e.dom=e.dom||t[0]}if(!e.dom)throw new Error("Container can not be empty!");if(!e.data||!e.data.length)throw new Error("Data must be an array and must have more than one element!");this._opts=e,e=null,t=null,this._setting(),this.fire("initialize"),this._renderWrapper(),this._initPlugins(),this._bindHandler(),this.fire("initialized"),this._autoPlay()};d.VERSION="2.1.4",d.EVENTS=["initialize","initialized","pluginInitialize","pluginInitialized","renderComplete","slide","slideStart","slideEnd","slideChange","slideChanged","slideRestore","slideRestored","loadData","reset","destroy"],d.EASING=[["linear","ease","ease-in","ease-out","ease-in-out"],/cubic-bezier\(([^\d]*(\d+.?\d*)[^\,]*\,?){4}\)/],d.FIX_PAGE_TAGS=["SELECT","INPUT","TEXTAREA","BUTTON","LABEL"],d.NODE_TYPE={unknown:"unknown",empty:"empty",pic:"pic",dom:"dom",html:"html",node:"node",element:"element"},d.TRANSITION_END_EVENT=function(){var t=document.createElement("fakeElement"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(var i in e)if(e.hasOwnProperty(i)&&void 0!==t.style[i])return e[i];return null}(),d.DEVICE_EVENTS=function(){var e=!!("ontouchstart"in t&&!/Mac OS X /.test(t.navigator.userAgent)||t.DocumentTouch&&document instanceof t.DocumentTouch);return{hasTouch:e,startEvt:e?"touchstart":"mousedown",moveEvt:e?"touchmove":"mousemove",endEvt:e?"touchend":"mouseup",cancelEvt:e?"touchcancel":"mouseout",resizeEvt:"onorientationchange"in t?"orientationchange":"resize"}}(),d.extend=function(){var t,e,i=arguments;switch(i.length){case 0:return;case 1:t=d.prototype,e=i[0];break;case 2:t=i[0],e=i[1]}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},d.plugins={},d.regPlugin=function(t,e){d.plugins[t]=d.plugins[t]||e},d._animateFuncs={normal:function(){function t(t,e,i,n,s){t.style.webkitTransform="translateZ(0) translate"+e+"("+(s+i*(n-1))+"px)"}return t.effect="transform",t}()};var c=d.prototype;c.extend=d.extend,c._setting=function(){var s=this;s._plugins=d.plugins,s._animateFuncs=d._animateFuncs,s._holding=!1,s._locking=!1,s._intermediateScene=null,s._transitionEndHandler=null,s._LSN={autoPlay:null,resize:null,transitionEnd:null},s.currentEl=null,s._EventHandle={},s.onMoving=!1,s.onSliding=!1,s.direction=null;var a=this._opts;s.wrap=a.dom,s.data=a.data,s.isVertical=!!a.isVertical,s.isOverspread=!!a.isOverspread,s.duration=a.duration||2e3,s.initIndex=a.initIndex>0&&a.initIndex<=a.data.length-1?a.initIndex:0,s.fixPage=function(){var t=a.fixPage;return t===!1||0===t?!1:n(t)&&t.length>0||"string"==typeof t&&""!==t?[].concat(t).toString():!0}(),s.fillSeam=!!a.fillSeam,s.slideIndex=s.slideIndex||s.initIndex||0,s.axis=s.isVertical?"Y":"X",s.reverseAxis="Y"===s.axis?"X":"Y",s.width="number"==typeof a.width?a.width:s.wrap.offsetWidth,s.height="number"==typeof a.height?a.height:s.wrap.offsetHeight,s.ratio=s.height/s.width,s.scale=s.isVertical?s.height:s.width,s.offset=s.offset||{X:0,Y:0},s.isTouchable=null==a.isTouchable?!0:!!a.isTouchable,s.isLooping=a.isLooping&&s.data.length>1?!0:!1,s.delay=a.delay||0,s.isAutoplay=a.isAutoplay&&s.data.length>1?!0:!1,s.animateType=a.animateType in s._animateFuncs?a.animateType:"normal",s._animateFunc=s._animateFuncs[s.animateType],s._animateReverse=function(){var t=[];for(var e in s._animateFuncs)s._animateFuncs.hasOwnProperty(e)&&s._animateFuncs[e].reverse&&t.push(e);return t}(),s.isVertical&&"card"===s.animateType&&(s.isOverspread=!0),s.log=a.isDebug?function(){t.console.log.apply(t.console,arguments)}:e,s._damping=function(){var t=s.scale>>1,e=t>>1,i=e>>2;return function(n){var s,a=Math.abs(n);return s=t>a?a>>1:t+e>a?e+(a-t>>2):e+i+(a-t-e>>3),n>0?s:-s}}(),s.animateTime=null!=a.animateTime&&a.animateTime>-1?a.animateTime:300,s.animateEasing=i(a.animateEasing,d.EASING[0])||d.EASING[1].test(a.animateEasing)?a.animateEasing:"ease",s.deviceEvents=d.DEVICE_EVENTS,s.fingerRecognitionRange=a.fingerRecognitionRange>-1?parseInt(a.fingerRecognitionRange):10,s.events={},d.EVENTS.forEach(function(t){var e=a["on"+t.toLowerCase()];"function"==typeof e&&s.on(t,e,1)}),s.pluginConfig=function(){var t={};return n(a.plugins)&&a.plugins.forEach(function(e){n(e)?t[e[0]]=e.slice(1):"string"==typeof e&&(t[e]=[])}),t}()},c._initPlugins=function(){var t=this.pluginConfig,e=this._plugins;for(var i in t)t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&e[i]&&"function"==typeof e[i]&&typeof e[i].apply&&e[i].apply(this,t[i]);this.fire("pluginInitialized")},c._itemType=function(t){if(isNaN(t)||(t=this.data[t]),t.hasOwnProperty("type"))return t.type;var e,i=t.content,n=d.NODE_TYPE;return e=null==i?n.empty:Boolean(i.nodeName)&&Boolean(i.nodeType)?n.node:"string"==typeof i?o(i)?n.pic:n.html:n.unknown,t.type=e,e},c._renderItem=function(t,e){var i,n=this,s=this.data.length,a=function(){var e=' src="'+i.content+'"';e+=i.height/i.width>n.ratio?' height="100%"':' width="100%"',n.isOverspread&&(t.style.cssText+="background-image:url("+i.content+");background-repeat:no-repeat;background-position:50% 50%;background-size:cover",e+=' style="display:block;opacity:0;height:100%;width:100%;"'),t.innerHTML=""};if(t.innerHTML="",t.style.background="",this.isLooping||null!=this.data[e]){e=(s+e)%s,i=this.data[e];var r=this._itemType(i),h=d.NODE_TYPE;switch(t.className="islider-"+r,r){case h.pic:if(2===i.load)a();else{var o=new Image;o.src=i.content,o.onload=function(){i.height=o.height,i.width=o.width,a(),i.load=2}}break;case h.dom:case h.html:t.innerHTML=i.content;break;case h.node:case h.element:if(11===i.content.nodeType){var l=document.createElement("div");l.appendChild(i.content),i.content=l}t.appendChild(i.content)}}},c._renderIntermediateScene=function(){null!=this._intermediateScene&&(this._renderItem.apply(this,this._intermediateScene),this._intermediateScene=null)},c._changedStyles=function(){var t=["islider-prev","islider-active","islider-next"];this.els.forEach(function(e,i){h(e,t.join("|")),r(e,t[i]),this.fillSeam&&this.originScale(e)}.bind(this))},c._renderWrapper=function(){var e;this.outer?(e=this.outer,e.innerHTML=""):e=document.createElement("ul"),e.className="islider-outer",this.els=[];for(var i=0;3>i;i++){var n=document.createElement("li");this.els.push(n),this._animateFunc(n,this.axis,this.scale,i,0),this.fixPage||(n.style.overflow="auto"),!this.isVertical||"rotate"!==this.animateType&&"flip"!==this.animateType?this._renderItem(n,i-1+this.slideIndex):this._renderItem(n,1-i+this.slideIndex),e.appendChild(n)}this._changedStyles(),this.fillSeam&&this.els.forEach(function(t,e){r(t,"islider-sliding"+(1===e?"-focus":""))}),t.setTimeout(function(){this._preloadImg(this.slideIndex)}.bind(this),200),this.outer||(this.outer=e,this.wrap.appendChild(e)),this.currentEl=this.els[1],this.fire("renderComplete",this.slideIndex,this.currentEl,this)},c._preloadImg=function(t){if(this.data.length>3){var e=this.data,i=e.length,n=this,s=function(t){var i=e[t];if("pic"===n._itemType(i)&&!i.load){var s=new Image;s.src=i.content,s.onload=function(){i.width=s.width,i.height=s.height,i.load=2},i.load=1}};s((t+2)%i),s((t-2+i)%i)}},c._watchTransitionEnd=function(e,i){this._unWatchTransitionEnd();var n=function(){this._unWatchTransitionEnd(),"slideChanged"===i&&this._changedStyles(),this.fire.call(this,i,this.slideIndex,this.currentEl,this),this._renderIntermediateScene(),this.play(),this.onSliding=!1,this.direction=null}.bind(this);d.TRANSITION_END_EVENT?(this.currentEl.addEventListener(d.TRANSITION_END_EVENT,n),this._transitionEndHandler={el:this.currentEl,handler:n}):this._LSN.transitionEnd=t.setTimeout(n,e)},c._unWatchTransitionEnd=function(){this._LSN.transitionEnd&&t.clearTimeout(this._LSN.transitionEnd),null!==this._transitionEndHandler&&(this._transitionEndHandler.el.removeEventListener(d.TRANSITION_END_EVENT,this._transitionEndHandler.handler),this._transitionEndHandler=null)},c._bindHandler=function(){var e=this.outer,i=this.deviceEvents;this.isTouchable&&(i.hasTouch||(e.style.cursor="pointer",e.ondragstart=function(t){return t?!1:!0}),e.addEventListener(i.startEvt,this),e.addEventListener(i.moveEvt,this),e.addEventListener(i.endEvt,this),!i.hasTouch&&e.addEventListener("mouseout",this)),t.addEventListener(i.resizeEvt,this),t.addEventListener("focus",this,!1),t.addEventListener("blur",this,!1)},c.handleEvent=function(t){var e=this.deviceEvents;switch(t.type){case"mousedown":if(0!==t.button)break;case"touchstart":this.startHandler(t);break;case e.moveEvt:this.moveHandler(t);break;case e.endEvt:case e.cancelEvt:this.endHandler(t);break;case e.resizeEvt:this.resizeHandler();break;case"focus":this.play();break;case"blur":this.pause()}},c.startHandler=function(t){if(this.fixPage&&d.FIX_PAGE_TAGS.indexOf(t.target.tagName.toUpperCase())<0&&!this._isItself(t.target)&&t.preventDefault(),!this._holding&&!this._locking){var e=this.deviceEvents;this.onMoving=!0,this.pause(),this.fire("slideStart",t,this),this.startTime=(new Date).getTime(),this.startX=e.hasTouch?t.targetTouches[0].pageX:t.pageX,this.startY=e.hasTouch?t.targetTouches[0].pageY:t.pageY}},c.moveHandler=function(t){if(this.onMoving){var e=this.deviceEvents,i=this.data.length,n=this.axis,s=this.reverseAxis,a={};t.hasOwnProperty("offsetRatio")?(a[n]=t.offsetRatio*this.scale,a[s]=0):(a.X=e.hasTouch?t.targetTouches[0].pageX-this.startX:t.pageX-this.startX,a.Y=e.hasTouch?t.targetTouches[0].pageY-this.startY:t.pageY-this.startY),this.offset=a,t.offsetRatio=a[n]/this.scale,Math.abs(a[n])-Math.abs(a[s])>10&&(t.preventDefault(),this._unWatchTransitionEnd(),this.isLooping||(a[n]>0&&0===this.slideIndex||a[n]<0&&this.slideIndex===i-1)&&(a[n]=this._damping(a[n])),this.els.forEach(function(t,e){t.style.visibility="visible",t.style.webkitTransition="none",this._animateFunc(t,n,this.scale,e,a[n],a[n]),this.fillSeam&&this.seamScale(t)}.bind(this)),this.fire("slide",t,this))}},c.endHandler=function(e){function i(n){if(null!=n)if("A"===n.tagName){if(n.href)return"_blank"===n.getAttribute("target")?t.open(n.href):t.location.href=n.href,e.preventDefault(),!1}else{if("LI"===n.tagName&&n.className.search(/^islider\-/)>-1)return!1;i(n.parentNode)}}if(this.onMoving){this.onMoving=!1;var n=this.offset,s=this.axis,a=this.scale/2,r=(new Date).getTime(),h=this.fingerRecognitionRange;a=r-this.startTime>300?a:14;var o=Math.abs(n[s]),l=Math.abs(n[this.reverseAxis]);this.fire("slideEnd",e,this),n[s]>=a&&o>l?this.slideTo(this.slideIndex-1):n[s]<-a&&o>l?this.slideTo(this.slideIndex+1):Math.abs(this.offset[s])>=h&&this.slideTo(this.slideIndex),Math.abs(this.offset[s])=1e3&&n&&t.clearInterval(n)}.bind(this),12)):(n&&t.clearTimeout(n),n=t.setTimeout(function(){(this.height!==this.wrap.offsetHeight||this.width!==this.wrap.offsetWidth)&&(n&&t.clearInterval(n),this.reset())}.bind(this),200))},c.slideTo=function(t,e){if(this.isAutoplay&&this.pause(),!this._locking){this.unhold(),this.onSliding=!0;var n,s=this.animateTime,a=this.animateType,o=this._animateFunc,l=this.data,d=this.els,c=this.axis,u=t,f=t-this.slideIndex,p=this.offset,g=0;"object"==typeof e&&(e.animateTime>-1&&(s=e.animateTime),"string"==typeof e.animateType&&e.animateType in this._animateFuncs&&(a=e.animateType,o=this._animateFuncs[a])),0!==p[c]&&(g=Math.abs(p[c])/this.scale*s),Math.abs(f)>1&&this._renderItem(f>0?this.els[2]:this.els[0],u),this._preloadImg(u),l[u]?this.slideIndex=u:this.isLooping?this.slideIndex=f>0?0:l.length-1:f=0;var m,v,E;0===f?n="slideRestore":((this.isVertical&&i(a,this._animateReverse))^f>0?(d.push(d.shift()),m=d[2],v=d[0],E=1):(d.unshift(d.pop()),m=d[0],v=d[2],E=-1),this.currentEl=d[1],1===Math.abs(f)?(this._renderIntermediateScene(),this._renderItem(m,u+f)):Math.abs(f)>1&&(this._renderItem(m,u+E),this._intermediateScene=[v,u-E]),m.style.webkitTransition="none",g=s-g,n="slideChange",this.fillSeam&&(d.forEach(function(t){h(t,"islider-sliding|islider-sliding-focus")}),r(this.currentEl,"islider-sliding-focus"),r(m,"islider-sliding")),this.direction=E);for(var _=0;3>_;_++)d[_]!==m&&(d[_].style.webkitTransition=(o.effect||"all")+" "+g+"ms "+this.animateEasing),o.call(this,d[_],c,this.scale,_,0,E),this.fillSeam&&this.seamScale(d[_]);this._watchTransitionEnd(g,n+"d"),this.fire(n,this.slideIndex,this.currentEl,this)}},c.slideNext=function(){this.slideTo.apply(this,[this.slideIndex+1].concat(l(arguments)))},c.slidePrev=function(){this.slideTo.apply(this,[this.slideIndex-1].concat(l(arguments)))},c.regPlugin=function(){var t=l(arguments),e=t.shift(),n=t[0];(this._plugins.hasOwnProperty(e)||"function"==typeof n)&&("function"==typeof n&&(this._plugins[e]=n,t.shift()),i(e,this._opts.plugins)||(this._opts.plugins.push(t.length?[].concat([e],t):e),"function"==typeof this._plugins[e]&&this._plugins[e].apply(this,t)))},c.bind=c.delegate=function(e,i,n){function s(e){for(var s=t.event?t.event:e,a=s.target,r=document.querySelectorAll(i),h=0;h-1)return this.wrap.removeEventListener(t,this._EventHandle[n][1][s]),this._EventHandle[n][0][s]=this._EventHandle[n][1][s]=null,!0}return!1},c.destroy=function(){var e=this.outer,i=this.deviceEvents;this.fire("destroy"),this.isTouchable&&(e.removeEventListener(i.startEvt,this),e.removeEventListener(i.moveEvt,this),e.removeEventListener(i.endEvt,this),!i.hasTouch&&e.removeEventListener("mouseout",this)),t.removeEventListener(i.resizeEvt,this),t.removeEventListener("focus",this),t.removeEventListener("blur",this);var n;for(n in this._EventHandle)for(var s=this._EventHandle[n][1],a=0;a-1&&delete this.events[t][i]}},c.fire=function(t){var e=l(arguments,1);t.split(/\x20+/).forEach(function(t){if(t in this.events)for(var i=this.events[t],n=0;n0?t.setTimeout(this.play.bind(this),this.delay):this.play()},c.play=function(){this.pause(),this.isAutoplay&&(this.isLooping||this.slideIndex-1?(i=i.split(","),n.X=parseFloat(i[0]),n.Y=parseFloat(i[1])):n.Y=n.X=parseFloat(i),n[this.axis]*=1.001,"scale("+n.X+", "+n.Y+")")}.bind(this)):t.style.webkitTransform+="scale"+this.axis+"(1.001)"},c.originScale=function(t){var e=/([\x20]?scale)([XY]?)\(([^\)]+)\)/;t.style.webkitTransform=t.style.webkitTransform.replace(e,function(t,e,i,n){return t={},i?"1.001"===n?"":(t[i]=parseFloat(n),"scale"+this.axis+"("+(i===this.axis?t[this.axis]/1.001:1)+")"):(n.indexOf(",")>-1?(n=n.split(","),t.X=parseFloat(n[0]),t.Y=parseFloat(n[1])):t.Y=t.X=parseFloat(n),t[this.axis]/=1.001,"scale("+t.X+", "+t.Y+")")}.bind(this))},c._isItself=function(t){var e=this.fixPage;if("string"==typeof e){for(var i,n=[],s=t;!a(s,"islider-outer")&&s!==this.wrap;)n.push(s),s=s.parentNode;if(s=n.pop(),n.length)try{if(i=Array.prototype.slice.call(s.querySelectorAll(e)),i.length)for(var r=0;r-1)return!0}catch(h){return!1}}return!1},c.subjectTo=function(t,e){if(!(!t instanceof d)){var i=this;i.animateTime=t.animateTime,i.isLooping=t.isLooping,i.isAutoplay=!1,t.on("slideStart",function(t){i.startHandler(t)}),t.on("slide",function(t){i.moveHandler(t)}),t.on("slideEnd",function(t){i.endHandler(t)}),t.on("slideChange",function(t){var e=i.data.length,n=i.direction;n>0&&(t-i.slideIndex+e)%e===1?i.slideNext():0>n&&(t-i.slideIndex-e)%e===-1&&i.slidePrev()}),t.on("slideRestore",function(t){i.slideIndex!==t&&i.slideTo(t)})}},"function"==typeof require&&"object"==typeof module&&module&&"object"==typeof exports&&exports?module.exports=d:"function"==typeof define&&define.amd?define(function(){return d}):t.iSlider=t.iSlider||d}(this||window); \ No newline at end of file diff --git a/demo/public/js/iSlider.js b/demo/public/js/iSlider.js index 5d29863c..dd876646 100644 --- a/demo/public/js/iSlider.js +++ b/demo/public/js/iSlider.js @@ -1677,7 +1677,10 @@ }; /** - * reload Data & render + * Reload Data & render + * + * @param {Array} data + * @param {Number} initIndex * @public */ iSliderPrototype.loadData = function (data, initIndex) { @@ -1691,7 +1694,7 @@ }; /** - * Add dynamic data + * Additional members to the end of the data sequence * * @param {Object|Array} sceneData * @description @@ -1703,11 +1706,11 @@ iSliderPrototype.addData = function (sceneData) { var len = this.data.length; this.data = this.data.concat(sceneData); - console.log('addData', len - 1 === this.slideIndex); if (this.isLooping && this.slideIndex === 0) { this._renderItem(this.els[0], this.data.length - 1); } else if (len - 1 === this.slideIndex) { this._renderItem(this.els[2], len); + this._autoPlay(); // restart } }; diff --git a/src/js/iSlider.js b/src/js/iSlider.js index 5d29863c..c78e5de5 100644 --- a/src/js/iSlider.js +++ b/src/js/iSlider.js @@ -1677,7 +1677,10 @@ }; /** - * reload Data & render + * Reload Data & render + * + * @param {Array} data + * @param {Number} initIndex * @public */ iSliderPrototype.loadData = function (data, initIndex) { @@ -1691,7 +1694,7 @@ }; /** - * Add dynamic data + * Add scenes to the end of the data datasheets * * @param {Object|Array} sceneData * @description @@ -1700,14 +1703,14 @@ * Array: * [{content:...}, {content:...}, ...] */ - iSliderPrototype.addData = function (sceneData) { + iSliderPrototype.pushData = function (sceneData) { var len = this.data.length; this.data = this.data.concat(sceneData); - console.log('addData', len - 1 === this.slideIndex); if (this.isLooping && this.slideIndex === 0) { this._renderItem(this.els[0], this.data.length - 1); } else if (len - 1 === this.slideIndex) { this._renderItem(this.els[2], len); + this._autoPlay(); // restart } }; From b49481556024b1cd47f684d78e114fdd13720207 Mon Sep 17 00:00:00 2001 From: shinate Date: Thu, 17 Mar 2016 15:20:06 +0800 Subject: [PATCH 3/9] add demo --- build/iSlider.js | 4 ++-- build/iSlider.min.js | 2 +- demo/add_dynamic_data.html | 8 ++------ demo/index_chinese.html | 3 ++- demo/public/js/iSlider.js | 4 ++-- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/build/iSlider.js b/build/iSlider.js index dd876646..c78e5de5 100644 --- a/build/iSlider.js +++ b/build/iSlider.js @@ -1694,7 +1694,7 @@ }; /** - * Additional members to the end of the data sequence + * Add scenes to the end of the data datasheets * * @param {Object|Array} sceneData * @description @@ -1703,7 +1703,7 @@ * Array: * [{content:...}, {content:...}, ...] */ - iSliderPrototype.addData = function (sceneData) { + iSliderPrototype.pushData = function (sceneData) { var len = this.data.length; this.data = this.data.concat(sceneData); if (this.isLooping && this.slideIndex === 0) { diff --git a/build/iSlider.min.js b/build/iSlider.min.js index eaf3f00a..e6dafe5d 100644 --- a/build/iSlider.min.js +++ b/build/iSlider.min.js @@ -1 +1 @@ -!function(t){"use strict";function e(){}function i(t,e){return e.indexOf(t)>-1}function n(t){return"[object Array]"===Object.prototype.toString.call(t)}function s(t){return"[object Object]"===Object.prototype.toString.call(t)}function a(t,e){return t.className.match(new RegExp("(\\s|^)("+e+")(\\s|$)"))}function r(t,e){a(t,e)||(t.className+=" "+e)}function h(t,e){a(t,e)&&(t.className=t.className.replace(RegExp("(\\s|^)("+e+")(\\s|$)"),"$3"))}function o(t){return/<\/?[^>]*>/.test(t)?!1:/^(?:(https|http|ftp|rtsp|mms):)?(\/\/)?(\w+:{0,1}\w*@)?([^\?#:\/]+\.[a-z]+|\d+\.\d+\.\d+\.\d+)?(:[0-9]+)?((?:\.?\/)?([^\?#]*)?(\?[^#]+)?(#.+)?)?$/.test(t)}function l(t){return Array.prototype.slice.apply(t,Array.prototype.slice.call(arguments,1))}var d=function(){var t=l(arguments,0,3);if(!t.length)throw new Error("Parameters required!");var e=s(t.slice(-1)[0])?t.pop():{};switch(t.length){case 2:e.data=e.data||t[1];case 1:e.dom=e.dom||t[0]}if(!e.dom)throw new Error("Container can not be empty!");if(!e.data||!e.data.length)throw new Error("Data must be an array and must have more than one element!");this._opts=e,e=null,t=null,this._setting(),this.fire("initialize"),this._renderWrapper(),this._initPlugins(),this._bindHandler(),this.fire("initialized"),this._autoPlay()};d.VERSION="2.1.4",d.EVENTS=["initialize","initialized","pluginInitialize","pluginInitialized","renderComplete","slide","slideStart","slideEnd","slideChange","slideChanged","slideRestore","slideRestored","loadData","reset","destroy"],d.EASING=[["linear","ease","ease-in","ease-out","ease-in-out"],/cubic-bezier\(([^\d]*(\d+.?\d*)[^\,]*\,?){4}\)/],d.FIX_PAGE_TAGS=["SELECT","INPUT","TEXTAREA","BUTTON","LABEL"],d.NODE_TYPE={unknown:"unknown",empty:"empty",pic:"pic",dom:"dom",html:"html",node:"node",element:"element"},d.TRANSITION_END_EVENT=function(){var t=document.createElement("fakeElement"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(var i in e)if(e.hasOwnProperty(i)&&void 0!==t.style[i])return e[i];return null}(),d.DEVICE_EVENTS=function(){var e=!!("ontouchstart"in t&&!/Mac OS X /.test(t.navigator.userAgent)||t.DocumentTouch&&document instanceof t.DocumentTouch);return{hasTouch:e,startEvt:e?"touchstart":"mousedown",moveEvt:e?"touchmove":"mousemove",endEvt:e?"touchend":"mouseup",cancelEvt:e?"touchcancel":"mouseout",resizeEvt:"onorientationchange"in t?"orientationchange":"resize"}}(),d.extend=function(){var t,e,i=arguments;switch(i.length){case 0:return;case 1:t=d.prototype,e=i[0];break;case 2:t=i[0],e=i[1]}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},d.plugins={},d.regPlugin=function(t,e){d.plugins[t]=d.plugins[t]||e},d._animateFuncs={normal:function(){function t(t,e,i,n,s){t.style.webkitTransform="translateZ(0) translate"+e+"("+(s+i*(n-1))+"px)"}return t.effect="transform",t}()};var c=d.prototype;c.extend=d.extend,c._setting=function(){var s=this;s._plugins=d.plugins,s._animateFuncs=d._animateFuncs,s._holding=!1,s._locking=!1,s._intermediateScene=null,s._transitionEndHandler=null,s._LSN={autoPlay:null,resize:null,transitionEnd:null},s.currentEl=null,s._EventHandle={},s.onMoving=!1,s.onSliding=!1,s.direction=null;var a=this._opts;s.wrap=a.dom,s.data=a.data,s.isVertical=!!a.isVertical,s.isOverspread=!!a.isOverspread,s.duration=a.duration||2e3,s.initIndex=a.initIndex>0&&a.initIndex<=a.data.length-1?a.initIndex:0,s.fixPage=function(){var t=a.fixPage;return t===!1||0===t?!1:n(t)&&t.length>0||"string"==typeof t&&""!==t?[].concat(t).toString():!0}(),s.fillSeam=!!a.fillSeam,s.slideIndex=s.slideIndex||s.initIndex||0,s.axis=s.isVertical?"Y":"X",s.reverseAxis="Y"===s.axis?"X":"Y",s.width="number"==typeof a.width?a.width:s.wrap.offsetWidth,s.height="number"==typeof a.height?a.height:s.wrap.offsetHeight,s.ratio=s.height/s.width,s.scale=s.isVertical?s.height:s.width,s.offset=s.offset||{X:0,Y:0},s.isTouchable=null==a.isTouchable?!0:!!a.isTouchable,s.isLooping=a.isLooping&&s.data.length>1?!0:!1,s.delay=a.delay||0,s.isAutoplay=a.isAutoplay&&s.data.length>1?!0:!1,s.animateType=a.animateType in s._animateFuncs?a.animateType:"normal",s._animateFunc=s._animateFuncs[s.animateType],s._animateReverse=function(){var t=[];for(var e in s._animateFuncs)s._animateFuncs.hasOwnProperty(e)&&s._animateFuncs[e].reverse&&t.push(e);return t}(),s.isVertical&&"card"===s.animateType&&(s.isOverspread=!0),s.log=a.isDebug?function(){t.console.log.apply(t.console,arguments)}:e,s._damping=function(){var t=s.scale>>1,e=t>>1,i=e>>2;return function(n){var s,a=Math.abs(n);return s=t>a?a>>1:t+e>a?e+(a-t>>2):e+i+(a-t-e>>3),n>0?s:-s}}(),s.animateTime=null!=a.animateTime&&a.animateTime>-1?a.animateTime:300,s.animateEasing=i(a.animateEasing,d.EASING[0])||d.EASING[1].test(a.animateEasing)?a.animateEasing:"ease",s.deviceEvents=d.DEVICE_EVENTS,s.fingerRecognitionRange=a.fingerRecognitionRange>-1?parseInt(a.fingerRecognitionRange):10,s.events={},d.EVENTS.forEach(function(t){var e=a["on"+t.toLowerCase()];"function"==typeof e&&s.on(t,e,1)}),s.pluginConfig=function(){var t={};return n(a.plugins)&&a.plugins.forEach(function(e){n(e)?t[e[0]]=e.slice(1):"string"==typeof e&&(t[e]=[])}),t}()},c._initPlugins=function(){var t=this.pluginConfig,e=this._plugins;for(var i in t)t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&e[i]&&"function"==typeof e[i]&&typeof e[i].apply&&e[i].apply(this,t[i]);this.fire("pluginInitialized")},c._itemType=function(t){if(isNaN(t)||(t=this.data[t]),t.hasOwnProperty("type"))return t.type;var e,i=t.content,n=d.NODE_TYPE;return e=null==i?n.empty:Boolean(i.nodeName)&&Boolean(i.nodeType)?n.node:"string"==typeof i?o(i)?n.pic:n.html:n.unknown,t.type=e,e},c._renderItem=function(t,e){var i,n=this,s=this.data.length,a=function(){var e=' src="'+i.content+'"';e+=i.height/i.width>n.ratio?' height="100%"':' width="100%"',n.isOverspread&&(t.style.cssText+="background-image:url("+i.content+");background-repeat:no-repeat;background-position:50% 50%;background-size:cover",e+=' style="display:block;opacity:0;height:100%;width:100%;"'),t.innerHTML=""};if(t.innerHTML="",t.style.background="",this.isLooping||null!=this.data[e]){e=(s+e)%s,i=this.data[e];var r=this._itemType(i),h=d.NODE_TYPE;switch(t.className="islider-"+r,r){case h.pic:if(2===i.load)a();else{var o=new Image;o.src=i.content,o.onload=function(){i.height=o.height,i.width=o.width,a(),i.load=2}}break;case h.dom:case h.html:t.innerHTML=i.content;break;case h.node:case h.element:if(11===i.content.nodeType){var l=document.createElement("div");l.appendChild(i.content),i.content=l}t.appendChild(i.content)}}},c._renderIntermediateScene=function(){null!=this._intermediateScene&&(this._renderItem.apply(this,this._intermediateScene),this._intermediateScene=null)},c._changedStyles=function(){var t=["islider-prev","islider-active","islider-next"];this.els.forEach(function(e,i){h(e,t.join("|")),r(e,t[i]),this.fillSeam&&this.originScale(e)}.bind(this))},c._renderWrapper=function(){var e;this.outer?(e=this.outer,e.innerHTML=""):e=document.createElement("ul"),e.className="islider-outer",this.els=[];for(var i=0;3>i;i++){var n=document.createElement("li");this.els.push(n),this._animateFunc(n,this.axis,this.scale,i,0),this.fixPage||(n.style.overflow="auto"),!this.isVertical||"rotate"!==this.animateType&&"flip"!==this.animateType?this._renderItem(n,i-1+this.slideIndex):this._renderItem(n,1-i+this.slideIndex),e.appendChild(n)}this._changedStyles(),this.fillSeam&&this.els.forEach(function(t,e){r(t,"islider-sliding"+(1===e?"-focus":""))}),t.setTimeout(function(){this._preloadImg(this.slideIndex)}.bind(this),200),this.outer||(this.outer=e,this.wrap.appendChild(e)),this.currentEl=this.els[1],this.fire("renderComplete",this.slideIndex,this.currentEl,this)},c._preloadImg=function(t){if(this.data.length>3){var e=this.data,i=e.length,n=this,s=function(t){var i=e[t];if("pic"===n._itemType(i)&&!i.load){var s=new Image;s.src=i.content,s.onload=function(){i.width=s.width,i.height=s.height,i.load=2},i.load=1}};s((t+2)%i),s((t-2+i)%i)}},c._watchTransitionEnd=function(e,i){this._unWatchTransitionEnd();var n=function(){this._unWatchTransitionEnd(),"slideChanged"===i&&this._changedStyles(),this.fire.call(this,i,this.slideIndex,this.currentEl,this),this._renderIntermediateScene(),this.play(),this.onSliding=!1,this.direction=null}.bind(this);d.TRANSITION_END_EVENT?(this.currentEl.addEventListener(d.TRANSITION_END_EVENT,n),this._transitionEndHandler={el:this.currentEl,handler:n}):this._LSN.transitionEnd=t.setTimeout(n,e)},c._unWatchTransitionEnd=function(){this._LSN.transitionEnd&&t.clearTimeout(this._LSN.transitionEnd),null!==this._transitionEndHandler&&(this._transitionEndHandler.el.removeEventListener(d.TRANSITION_END_EVENT,this._transitionEndHandler.handler),this._transitionEndHandler=null)},c._bindHandler=function(){var e=this.outer,i=this.deviceEvents;this.isTouchable&&(i.hasTouch||(e.style.cursor="pointer",e.ondragstart=function(t){return t?!1:!0}),e.addEventListener(i.startEvt,this),e.addEventListener(i.moveEvt,this),e.addEventListener(i.endEvt,this),!i.hasTouch&&e.addEventListener("mouseout",this)),t.addEventListener(i.resizeEvt,this),t.addEventListener("focus",this,!1),t.addEventListener("blur",this,!1)},c.handleEvent=function(t){var e=this.deviceEvents;switch(t.type){case"mousedown":if(0!==t.button)break;case"touchstart":this.startHandler(t);break;case e.moveEvt:this.moveHandler(t);break;case e.endEvt:case e.cancelEvt:this.endHandler(t);break;case e.resizeEvt:this.resizeHandler();break;case"focus":this.play();break;case"blur":this.pause()}},c.startHandler=function(t){if(this.fixPage&&d.FIX_PAGE_TAGS.indexOf(t.target.tagName.toUpperCase())<0&&!this._isItself(t.target)&&t.preventDefault(),!this._holding&&!this._locking){var e=this.deviceEvents;this.onMoving=!0,this.pause(),this.fire("slideStart",t,this),this.startTime=(new Date).getTime(),this.startX=e.hasTouch?t.targetTouches[0].pageX:t.pageX,this.startY=e.hasTouch?t.targetTouches[0].pageY:t.pageY}},c.moveHandler=function(t){if(this.onMoving){var e=this.deviceEvents,i=this.data.length,n=this.axis,s=this.reverseAxis,a={};t.hasOwnProperty("offsetRatio")?(a[n]=t.offsetRatio*this.scale,a[s]=0):(a.X=e.hasTouch?t.targetTouches[0].pageX-this.startX:t.pageX-this.startX,a.Y=e.hasTouch?t.targetTouches[0].pageY-this.startY:t.pageY-this.startY),this.offset=a,t.offsetRatio=a[n]/this.scale,Math.abs(a[n])-Math.abs(a[s])>10&&(t.preventDefault(),this._unWatchTransitionEnd(),this.isLooping||(a[n]>0&&0===this.slideIndex||a[n]<0&&this.slideIndex===i-1)&&(a[n]=this._damping(a[n])),this.els.forEach(function(t,e){t.style.visibility="visible",t.style.webkitTransition="none",this._animateFunc(t,n,this.scale,e,a[n],a[n]),this.fillSeam&&this.seamScale(t)}.bind(this)),this.fire("slide",t,this))}},c.endHandler=function(e){function i(n){if(null!=n)if("A"===n.tagName){if(n.href)return"_blank"===n.getAttribute("target")?t.open(n.href):t.location.href=n.href,e.preventDefault(),!1}else{if("LI"===n.tagName&&n.className.search(/^islider\-/)>-1)return!1;i(n.parentNode)}}if(this.onMoving){this.onMoving=!1;var n=this.offset,s=this.axis,a=this.scale/2,r=(new Date).getTime(),h=this.fingerRecognitionRange;a=r-this.startTime>300?a:14;var o=Math.abs(n[s]),l=Math.abs(n[this.reverseAxis]);this.fire("slideEnd",e,this),n[s]>=a&&o>l?this.slideTo(this.slideIndex-1):n[s]<-a&&o>l?this.slideTo(this.slideIndex+1):Math.abs(this.offset[s])>=h&&this.slideTo(this.slideIndex),Math.abs(this.offset[s])=1e3&&n&&t.clearInterval(n)}.bind(this),12)):(n&&t.clearTimeout(n),n=t.setTimeout(function(){(this.height!==this.wrap.offsetHeight||this.width!==this.wrap.offsetWidth)&&(n&&t.clearInterval(n),this.reset())}.bind(this),200))},c.slideTo=function(t,e){if(this.isAutoplay&&this.pause(),!this._locking){this.unhold(),this.onSliding=!0;var n,s=this.animateTime,a=this.animateType,o=this._animateFunc,l=this.data,d=this.els,c=this.axis,u=t,f=t-this.slideIndex,p=this.offset,g=0;"object"==typeof e&&(e.animateTime>-1&&(s=e.animateTime),"string"==typeof e.animateType&&e.animateType in this._animateFuncs&&(a=e.animateType,o=this._animateFuncs[a])),0!==p[c]&&(g=Math.abs(p[c])/this.scale*s),Math.abs(f)>1&&this._renderItem(f>0?this.els[2]:this.els[0],u),this._preloadImg(u),l[u]?this.slideIndex=u:this.isLooping?this.slideIndex=f>0?0:l.length-1:f=0;var m,v,E;0===f?n="slideRestore":((this.isVertical&&i(a,this._animateReverse))^f>0?(d.push(d.shift()),m=d[2],v=d[0],E=1):(d.unshift(d.pop()),m=d[0],v=d[2],E=-1),this.currentEl=d[1],1===Math.abs(f)?(this._renderIntermediateScene(),this._renderItem(m,u+f)):Math.abs(f)>1&&(this._renderItem(m,u+E),this._intermediateScene=[v,u-E]),m.style.webkitTransition="none",g=s-g,n="slideChange",this.fillSeam&&(d.forEach(function(t){h(t,"islider-sliding|islider-sliding-focus")}),r(this.currentEl,"islider-sliding-focus"),r(m,"islider-sliding")),this.direction=E);for(var _=0;3>_;_++)d[_]!==m&&(d[_].style.webkitTransition=(o.effect||"all")+" "+g+"ms "+this.animateEasing),o.call(this,d[_],c,this.scale,_,0,E),this.fillSeam&&this.seamScale(d[_]);this._watchTransitionEnd(g,n+"d"),this.fire(n,this.slideIndex,this.currentEl,this)}},c.slideNext=function(){this.slideTo.apply(this,[this.slideIndex+1].concat(l(arguments)))},c.slidePrev=function(){this.slideTo.apply(this,[this.slideIndex-1].concat(l(arguments)))},c.regPlugin=function(){var t=l(arguments),e=t.shift(),n=t[0];(this._plugins.hasOwnProperty(e)||"function"==typeof n)&&("function"==typeof n&&(this._plugins[e]=n,t.shift()),i(e,this._opts.plugins)||(this._opts.plugins.push(t.length?[].concat([e],t):e),"function"==typeof this._plugins[e]&&this._plugins[e].apply(this,t)))},c.bind=c.delegate=function(e,i,n){function s(e){for(var s=t.event?t.event:e,a=s.target,r=document.querySelectorAll(i),h=0;h-1)return this.wrap.removeEventListener(t,this._EventHandle[n][1][s]),this._EventHandle[n][0][s]=this._EventHandle[n][1][s]=null,!0}return!1},c.destroy=function(){var e=this.outer,i=this.deviceEvents;this.fire("destroy"),this.isTouchable&&(e.removeEventListener(i.startEvt,this),e.removeEventListener(i.moveEvt,this),e.removeEventListener(i.endEvt,this),!i.hasTouch&&e.removeEventListener("mouseout",this)),t.removeEventListener(i.resizeEvt,this),t.removeEventListener("focus",this),t.removeEventListener("blur",this);var n;for(n in this._EventHandle)for(var s=this._EventHandle[n][1],a=0;a-1&&delete this.events[t][i]}},c.fire=function(t){var e=l(arguments,1);t.split(/\x20+/).forEach(function(t){if(t in this.events)for(var i=this.events[t],n=0;n0?t.setTimeout(this.play.bind(this),this.delay):this.play()},c.play=function(){this.pause(),this.isAutoplay&&(this.isLooping||this.slideIndex-1?(i=i.split(","),n.X=parseFloat(i[0]),n.Y=parseFloat(i[1])):n.Y=n.X=parseFloat(i),n[this.axis]*=1.001,"scale("+n.X+", "+n.Y+")")}.bind(this)):t.style.webkitTransform+="scale"+this.axis+"(1.001)"},c.originScale=function(t){var e=/([\x20]?scale)([XY]?)\(([^\)]+)\)/;t.style.webkitTransform=t.style.webkitTransform.replace(e,function(t,e,i,n){return t={},i?"1.001"===n?"":(t[i]=parseFloat(n),"scale"+this.axis+"("+(i===this.axis?t[this.axis]/1.001:1)+")"):(n.indexOf(",")>-1?(n=n.split(","),t.X=parseFloat(n[0]),t.Y=parseFloat(n[1])):t.Y=t.X=parseFloat(n),t[this.axis]/=1.001,"scale("+t.X+", "+t.Y+")")}.bind(this))},c._isItself=function(t){var e=this.fixPage;if("string"==typeof e){for(var i,n=[],s=t;!a(s,"islider-outer")&&s!==this.wrap;)n.push(s),s=s.parentNode;if(s=n.pop(),n.length)try{if(i=Array.prototype.slice.call(s.querySelectorAll(e)),i.length)for(var r=0;r-1)return!0}catch(h){return!1}}return!1},c.subjectTo=function(t,e){if(!(!t instanceof d)){var i=this;i.animateTime=t.animateTime,i.isLooping=t.isLooping,i.isAutoplay=!1,t.on("slideStart",function(t){i.startHandler(t)}),t.on("slide",function(t){i.moveHandler(t)}),t.on("slideEnd",function(t){i.endHandler(t)}),t.on("slideChange",function(t){var e=i.data.length,n=i.direction;n>0&&(t-i.slideIndex+e)%e===1?i.slideNext():0>n&&(t-i.slideIndex-e)%e===-1&&i.slidePrev()}),t.on("slideRestore",function(t){i.slideIndex!==t&&i.slideTo(t)})}},"function"==typeof require&&"object"==typeof module&&module&&"object"==typeof exports&&exports?module.exports=d:"function"==typeof define&&define.amd?define(function(){return d}):t.iSlider=t.iSlider||d}(this||window); \ No newline at end of file +!function(t){"use strict";function e(){}function i(t,e){return e.indexOf(t)>-1}function n(t){return"[object Array]"===Object.prototype.toString.call(t)}function s(t){return"[object Object]"===Object.prototype.toString.call(t)}function a(t,e){return t.className.match(new RegExp("(\\s|^)("+e+")(\\s|$)"))}function r(t,e){a(t,e)||(t.className+=" "+e)}function h(t,e){a(t,e)&&(t.className=t.className.replace(RegExp("(\\s|^)("+e+")(\\s|$)"),"$3"))}function o(t){return/<\/?[^>]*>/.test(t)?!1:/^(?:(https|http|ftp|rtsp|mms):)?(\/\/)?(\w+:{0,1}\w*@)?([^\?#:\/]+\.[a-z]+|\d+\.\d+\.\d+\.\d+)?(:[0-9]+)?((?:\.?\/)?([^\?#]*)?(\?[^#]+)?(#.+)?)?$/.test(t)}function l(t){return Array.prototype.slice.apply(t,Array.prototype.slice.call(arguments,1))}var d=function(){var t=l(arguments,0,3);if(!t.length)throw new Error("Parameters required!");var e=s(t.slice(-1)[0])?t.pop():{};switch(t.length){case 2:e.data=e.data||t[1];case 1:e.dom=e.dom||t[0]}if(!e.dom)throw new Error("Container can not be empty!");if(!e.data||!e.data.length)throw new Error("Data must be an array and must have more than one element!");this._opts=e,e=null,t=null,this._setting(),this.fire("initialize"),this._renderWrapper(),this._initPlugins(),this._bindHandler(),this.fire("initialized"),this._autoPlay()};d.VERSION="2.1.4",d.EVENTS=["initialize","initialized","pluginInitialize","pluginInitialized","renderComplete","slide","slideStart","slideEnd","slideChange","slideChanged","slideRestore","slideRestored","loadData","reset","destroy"],d.EASING=[["linear","ease","ease-in","ease-out","ease-in-out"],/cubic-bezier\(([^\d]*(\d+.?\d*)[^\,]*\,?){4}\)/],d.FIX_PAGE_TAGS=["SELECT","INPUT","TEXTAREA","BUTTON","LABEL"],d.NODE_TYPE={unknown:"unknown",empty:"empty",pic:"pic",dom:"dom",html:"html",node:"node",element:"element"},d.TRANSITION_END_EVENT=function(){var t=document.createElement("fakeElement"),e={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(var i in e)if(e.hasOwnProperty(i)&&void 0!==t.style[i])return e[i];return null}(),d.DEVICE_EVENTS=function(){var e=!!("ontouchstart"in t&&!/Mac OS X /.test(t.navigator.userAgent)||t.DocumentTouch&&document instanceof t.DocumentTouch);return{hasTouch:e,startEvt:e?"touchstart":"mousedown",moveEvt:e?"touchmove":"mousemove",endEvt:e?"touchend":"mouseup",cancelEvt:e?"touchcancel":"mouseout",resizeEvt:"onorientationchange"in t?"orientationchange":"resize"}}(),d.extend=function(){var t,e,i=arguments;switch(i.length){case 0:return;case 1:t=d.prototype,e=i[0];break;case 2:t=i[0],e=i[1]}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},d.plugins={},d.regPlugin=function(t,e){d.plugins[t]=d.plugins[t]||e},d._animateFuncs={normal:function(){function t(t,e,i,n,s){t.style.webkitTransform="translateZ(0) translate"+e+"("+(s+i*(n-1))+"px)"}return t.effect="transform",t}()};var c=d.prototype;c.extend=d.extend,c._setting=function(){var s=this;s._plugins=d.plugins,s._animateFuncs=d._animateFuncs,s._holding=!1,s._locking=!1,s._intermediateScene=null,s._transitionEndHandler=null,s._LSN={autoPlay:null,resize:null,transitionEnd:null},s.currentEl=null,s._EventHandle={},s.onMoving=!1,s.onSliding=!1,s.direction=null;var a=this._opts;s.wrap=a.dom,s.data=a.data,s.isVertical=!!a.isVertical,s.isOverspread=!!a.isOverspread,s.duration=a.duration||2e3,s.initIndex=a.initIndex>0&&a.initIndex<=a.data.length-1?a.initIndex:0,s.fixPage=function(){var t=a.fixPage;return t===!1||0===t?!1:n(t)&&t.length>0||"string"==typeof t&&""!==t?[].concat(t).toString():!0}(),s.fillSeam=!!a.fillSeam,s.slideIndex=s.slideIndex||s.initIndex||0,s.axis=s.isVertical?"Y":"X",s.reverseAxis="Y"===s.axis?"X":"Y",s.width="number"==typeof a.width?a.width:s.wrap.offsetWidth,s.height="number"==typeof a.height?a.height:s.wrap.offsetHeight,s.ratio=s.height/s.width,s.scale=s.isVertical?s.height:s.width,s.offset=s.offset||{X:0,Y:0},s.isTouchable=null==a.isTouchable?!0:!!a.isTouchable,s.isLooping=a.isLooping&&s.data.length>1?!0:!1,s.delay=a.delay||0,s.isAutoplay=a.isAutoplay&&s.data.length>1?!0:!1,s.animateType=a.animateType in s._animateFuncs?a.animateType:"normal",s._animateFunc=s._animateFuncs[s.animateType],s._animateReverse=function(){var t=[];for(var e in s._animateFuncs)s._animateFuncs.hasOwnProperty(e)&&s._animateFuncs[e].reverse&&t.push(e);return t}(),s.isVertical&&"card"===s.animateType&&(s.isOverspread=!0),s.log=a.isDebug?function(){t.console.log.apply(t.console,arguments)}:e,s._damping=function(){var t=s.scale>>1,e=t>>1,i=e>>2;return function(n){var s,a=Math.abs(n);return s=t>a?a>>1:t+e>a?e+(a-t>>2):e+i+(a-t-e>>3),n>0?s:-s}}(),s.animateTime=null!=a.animateTime&&a.animateTime>-1?a.animateTime:300,s.animateEasing=i(a.animateEasing,d.EASING[0])||d.EASING[1].test(a.animateEasing)?a.animateEasing:"ease",s.deviceEvents=d.DEVICE_EVENTS,s.fingerRecognitionRange=a.fingerRecognitionRange>-1?parseInt(a.fingerRecognitionRange):10,s.events={},d.EVENTS.forEach(function(t){var e=a["on"+t.toLowerCase()];"function"==typeof e&&s.on(t,e,1)}),s.pluginConfig=function(){var t={};return n(a.plugins)&&a.plugins.forEach(function(e){n(e)?t[e[0]]=e.slice(1):"string"==typeof e&&(t[e]=[])}),t}()},c._initPlugins=function(){var t=this.pluginConfig,e=this._plugins;for(var i in t)t.hasOwnProperty(i)&&e.hasOwnProperty(i)&&e[i]&&"function"==typeof e[i]&&typeof e[i].apply&&e[i].apply(this,t[i]);this.fire("pluginInitialized")},c._itemType=function(t){if(isNaN(t)||(t=this.data[t]),t.hasOwnProperty("type"))return t.type;var e,i=t.content,n=d.NODE_TYPE;return e=null==i?n.empty:Boolean(i.nodeName)&&Boolean(i.nodeType)?n.node:"string"==typeof i?o(i)?n.pic:n.html:n.unknown,t.type=e,e},c._renderItem=function(t,e){var i,n=this,s=this.data.length,a=function(){var e=' src="'+i.content+'"';e+=i.height/i.width>n.ratio?' height="100%"':' width="100%"',n.isOverspread&&(t.style.cssText+="background-image:url("+i.content+");background-repeat:no-repeat;background-position:50% 50%;background-size:cover",e+=' style="display:block;opacity:0;height:100%;width:100%;"'),t.innerHTML=""};if(t.innerHTML="",t.style.background="",this.isLooping||null!=this.data[e]){e=(s+e)%s,i=this.data[e];var r=this._itemType(i),h=d.NODE_TYPE;switch(t.className="islider-"+r,r){case h.pic:if(2===i.load)a();else{var o=new Image;o.src=i.content,o.onload=function(){i.height=o.height,i.width=o.width,a(),i.load=2}}break;case h.dom:case h.html:t.innerHTML=i.content;break;case h.node:case h.element:if(11===i.content.nodeType){var l=document.createElement("div");l.appendChild(i.content),i.content=l}t.appendChild(i.content)}}},c._renderIntermediateScene=function(){null!=this._intermediateScene&&(this._renderItem.apply(this,this._intermediateScene),this._intermediateScene=null)},c._changedStyles=function(){var t=["islider-prev","islider-active","islider-next"];this.els.forEach(function(e,i){h(e,t.join("|")),r(e,t[i]),this.fillSeam&&this.originScale(e)}.bind(this))},c._renderWrapper=function(){var e;this.outer?(e=this.outer,e.innerHTML=""):e=document.createElement("ul"),e.className="islider-outer",this.els=[];for(var i=0;3>i;i++){var n=document.createElement("li");this.els.push(n),this._animateFunc(n,this.axis,this.scale,i,0),this.fixPage||(n.style.overflow="auto"),!this.isVertical||"rotate"!==this.animateType&&"flip"!==this.animateType?this._renderItem(n,i-1+this.slideIndex):this._renderItem(n,1-i+this.slideIndex),e.appendChild(n)}this._changedStyles(),this.fillSeam&&this.els.forEach(function(t,e){r(t,"islider-sliding"+(1===e?"-focus":""))}),t.setTimeout(function(){this._preloadImg(this.slideIndex)}.bind(this),200),this.outer||(this.outer=e,this.wrap.appendChild(e)),this.currentEl=this.els[1],this.fire("renderComplete",this.slideIndex,this.currentEl,this)},c._preloadImg=function(t){if(this.data.length>3){var e=this.data,i=e.length,n=this,s=function(t){var i=e[t];if("pic"===n._itemType(i)&&!i.load){var s=new Image;s.src=i.content,s.onload=function(){i.width=s.width,i.height=s.height,i.load=2},i.load=1}};s((t+2)%i),s((t-2+i)%i)}},c._watchTransitionEnd=function(e,i){this._unWatchTransitionEnd();var n=function(){this._unWatchTransitionEnd(),"slideChanged"===i&&this._changedStyles(),this.fire.call(this,i,this.slideIndex,this.currentEl,this),this._renderIntermediateScene(),this.play(),this.onSliding=!1,this.direction=null}.bind(this);d.TRANSITION_END_EVENT?(this.currentEl.addEventListener(d.TRANSITION_END_EVENT,n),this._transitionEndHandler={el:this.currentEl,handler:n}):this._LSN.transitionEnd=t.setTimeout(n,e)},c._unWatchTransitionEnd=function(){this._LSN.transitionEnd&&t.clearTimeout(this._LSN.transitionEnd),null!==this._transitionEndHandler&&(this._transitionEndHandler.el.removeEventListener(d.TRANSITION_END_EVENT,this._transitionEndHandler.handler),this._transitionEndHandler=null)},c._bindHandler=function(){var e=this.outer,i=this.deviceEvents;this.isTouchable&&(i.hasTouch||(e.style.cursor="pointer",e.ondragstart=function(t){return t?!1:!0}),e.addEventListener(i.startEvt,this),e.addEventListener(i.moveEvt,this),e.addEventListener(i.endEvt,this),!i.hasTouch&&e.addEventListener("mouseout",this)),t.addEventListener(i.resizeEvt,this),t.addEventListener("focus",this,!1),t.addEventListener("blur",this,!1)},c.handleEvent=function(t){var e=this.deviceEvents;switch(t.type){case"mousedown":if(0!==t.button)break;case"touchstart":this.startHandler(t);break;case e.moveEvt:this.moveHandler(t);break;case e.endEvt:case e.cancelEvt:this.endHandler(t);break;case e.resizeEvt:this.resizeHandler();break;case"focus":this.play();break;case"blur":this.pause()}},c.startHandler=function(t){if(this.fixPage&&d.FIX_PAGE_TAGS.indexOf(t.target.tagName.toUpperCase())<0&&!this._isItself(t.target)&&t.preventDefault(),!this._holding&&!this._locking){var e=this.deviceEvents;this.onMoving=!0,this.pause(),this.fire("slideStart",t,this),this.startTime=(new Date).getTime(),this.startX=e.hasTouch?t.targetTouches[0].pageX:t.pageX,this.startY=e.hasTouch?t.targetTouches[0].pageY:t.pageY}},c.moveHandler=function(t){if(this.onMoving){var e=this.deviceEvents,i=this.data.length,n=this.axis,s=this.reverseAxis,a={};t.hasOwnProperty("offsetRatio")?(a[n]=t.offsetRatio*this.scale,a[s]=0):(a.X=e.hasTouch?t.targetTouches[0].pageX-this.startX:t.pageX-this.startX,a.Y=e.hasTouch?t.targetTouches[0].pageY-this.startY:t.pageY-this.startY),this.offset=a,t.offsetRatio=a[n]/this.scale,Math.abs(a[n])-Math.abs(a[s])>10&&(t.preventDefault(),this._unWatchTransitionEnd(),this.isLooping||(a[n]>0&&0===this.slideIndex||a[n]<0&&this.slideIndex===i-1)&&(a[n]=this._damping(a[n])),this.els.forEach(function(t,e){t.style.visibility="visible",t.style.webkitTransition="none",this._animateFunc(t,n,this.scale,e,a[n],a[n]),this.fillSeam&&this.seamScale(t)}.bind(this)),this.fire("slide",t,this))}},c.endHandler=function(e){function i(n){if(null!=n)if("A"===n.tagName){if(n.href)return"_blank"===n.getAttribute("target")?t.open(n.href):t.location.href=n.href,e.preventDefault(),!1}else{if("LI"===n.tagName&&n.className.search(/^islider\-/)>-1)return!1;i(n.parentNode)}}if(this.onMoving){this.onMoving=!1;var n=this.offset,s=this.axis,a=this.scale/2,r=(new Date).getTime(),h=this.fingerRecognitionRange;a=r-this.startTime>300?a:14;var o=Math.abs(n[s]),l=Math.abs(n[this.reverseAxis]);this.fire("slideEnd",e,this),n[s]>=a&&o>l?this.slideTo(this.slideIndex-1):n[s]<-a&&o>l?this.slideTo(this.slideIndex+1):Math.abs(this.offset[s])>=h&&this.slideTo(this.slideIndex),Math.abs(this.offset[s])=1e3&&n&&t.clearInterval(n)}.bind(this),12)):(n&&t.clearTimeout(n),n=t.setTimeout(function(){(this.height!==this.wrap.offsetHeight||this.width!==this.wrap.offsetWidth)&&(n&&t.clearInterval(n),this.reset())}.bind(this),200))},c.slideTo=function(t,e){if(this.isAutoplay&&this.pause(),!this._locking){this.unhold(),this.onSliding=!0;var n,s=this.animateTime,a=this.animateType,o=this._animateFunc,l=this.data,d=this.els,c=this.axis,u=t,f=t-this.slideIndex,p=this.offset,g=0;"object"==typeof e&&(e.animateTime>-1&&(s=e.animateTime),"string"==typeof e.animateType&&e.animateType in this._animateFuncs&&(a=e.animateType,o=this._animateFuncs[a])),0!==p[c]&&(g=Math.abs(p[c])/this.scale*s),Math.abs(f)>1&&this._renderItem(f>0?this.els[2]:this.els[0],u),this._preloadImg(u),l[u]?this.slideIndex=u:this.isLooping?this.slideIndex=f>0?0:l.length-1:f=0;var m,v,E;0===f?n="slideRestore":((this.isVertical&&i(a,this._animateReverse))^f>0?(d.push(d.shift()),m=d[2],v=d[0],E=1):(d.unshift(d.pop()),m=d[0],v=d[2],E=-1),this.currentEl=d[1],1===Math.abs(f)?(this._renderIntermediateScene(),this._renderItem(m,u+f)):Math.abs(f)>1&&(this._renderItem(m,u+E),this._intermediateScene=[v,u-E]),m.style.webkitTransition="none",g=s-g,n="slideChange",this.fillSeam&&(d.forEach(function(t){h(t,"islider-sliding|islider-sliding-focus")}),r(this.currentEl,"islider-sliding-focus"),r(m,"islider-sliding")),this.direction=E);for(var _=0;3>_;_++)d[_]!==m&&(d[_].style.webkitTransition=(o.effect||"all")+" "+g+"ms "+this.animateEasing),o.call(this,d[_],c,this.scale,_,0,E),this.fillSeam&&this.seamScale(d[_]);this._watchTransitionEnd(g,n+"d"),this.fire(n,this.slideIndex,this.currentEl,this)}},c.slideNext=function(){this.slideTo.apply(this,[this.slideIndex+1].concat(l(arguments)))},c.slidePrev=function(){this.slideTo.apply(this,[this.slideIndex-1].concat(l(arguments)))},c.regPlugin=function(){var t=l(arguments),e=t.shift(),n=t[0];(this._plugins.hasOwnProperty(e)||"function"==typeof n)&&("function"==typeof n&&(this._plugins[e]=n,t.shift()),i(e,this._opts.plugins)||(this._opts.plugins.push(t.length?[].concat([e],t):e),"function"==typeof this._plugins[e]&&this._plugins[e].apply(this,t)))},c.bind=c.delegate=function(e,i,n){function s(e){for(var s=t.event?t.event:e,a=s.target,r=document.querySelectorAll(i),h=0;h-1)return this.wrap.removeEventListener(t,this._EventHandle[n][1][s]),this._EventHandle[n][0][s]=this._EventHandle[n][1][s]=null,!0}return!1},c.destroy=function(){var e=this.outer,i=this.deviceEvents;this.fire("destroy"),this.isTouchable&&(e.removeEventListener(i.startEvt,this),e.removeEventListener(i.moveEvt,this),e.removeEventListener(i.endEvt,this),!i.hasTouch&&e.removeEventListener("mouseout",this)),t.removeEventListener(i.resizeEvt,this),t.removeEventListener("focus",this),t.removeEventListener("blur",this);var n;for(n in this._EventHandle)for(var s=this._EventHandle[n][1],a=0;a-1&&delete this.events[t][i]}},c.fire=function(t){var e=l(arguments,1);t.split(/\x20+/).forEach(function(t){if(t in this.events)for(var i=this.events[t],n=0;n0?t.setTimeout(this.play.bind(this),this.delay):this.play()},c.play=function(){this.pause(),this.isAutoplay&&(this.isLooping||this.slideIndex-1?(i=i.split(","),n.X=parseFloat(i[0]),n.Y=parseFloat(i[1])):n.Y=n.X=parseFloat(i),n[this.axis]*=1.001,"scale("+n.X+", "+n.Y+")")}.bind(this)):t.style.webkitTransform+="scale"+this.axis+"(1.001)"},c.originScale=function(t){var e=/([\x20]?scale)([XY]?)\(([^\)]+)\)/;t.style.webkitTransform=t.style.webkitTransform.replace(e,function(t,e,i,n){return t={},i?"1.001"===n?"":(t[i]=parseFloat(n),"scale"+this.axis+"("+(i===this.axis?t[this.axis]/1.001:1)+")"):(n.indexOf(",")>-1?(n=n.split(","),t.X=parseFloat(n[0]),t.Y=parseFloat(n[1])):t.Y=t.X=parseFloat(n),t[this.axis]/=1.001,"scale("+t.X+", "+t.Y+")")}.bind(this))},c._isItself=function(t){var e=this.fixPage;if("string"==typeof e){for(var i,n=[],s=t;!a(s,"islider-outer")&&s!==this.wrap;)n.push(s),s=s.parentNode;if(s=n.pop(),n.length)try{if(i=Array.prototype.slice.call(s.querySelectorAll(e)),i.length)for(var r=0;r-1)return!0}catch(h){return!1}}return!1},c.subjectTo=function(t,e){if(!(!t instanceof d)){var i=this;i.animateTime=t.animateTime,i.isLooping=t.isLooping,i.isAutoplay=!1,t.on("slideStart",function(t){i.startHandler(t)}),t.on("slide",function(t){i.moveHandler(t)}),t.on("slideEnd",function(t){i.endHandler(t)}),t.on("slideChange",function(t){var e=i.data.length,n=i.direction;n>0&&(t-i.slideIndex+e)%e===1?i.slideNext():0>n&&(t-i.slideIndex-e)%e===-1&&i.slidePrev()}),t.on("slideRestore",function(t){i.slideIndex!==t&&i.slideTo(t)})}},"function"==typeof require&&"object"==typeof module&&module&&"object"==typeof exports&&exports?module.exports=d:"function"==typeof define&&define.amd?define(function(){return d}):t.iSlider=t.iSlider||d}(this||window); \ No newline at end of file diff --git a/demo/add_dynamic_data.html b/demo/add_dynamic_data.html index 23e41527..33d5b34c 100644 --- a/demo/add_dynamic_data.html +++ b/demo/add_dynamic_data.html @@ -35,7 +35,7 @@ @@ -147,13 +148,13 @@ // isVertical: 1, isLooping: 1, // isOverspread: 1, - animateType: 'rotate', +// animateType: 'rotate', // delay: 3000, - animateTime: 1000, -// fillSeam: 1, + animateTime: 5000, + fillSeam: 1, fixPage: ['[x="ooxx"]', 'div'], isDebug: 1, -// isAutoplay: true, + isAutoplay: true, duration: 5000, // plugins: [ // ['dot', {locate: 'relative'}], @@ -171,9 +172,9 @@ _: null }); - // islider.on('slideChange', function () { - // console.debug('Change event from method "on"', this, arguments); - // }); + // islider.on('slideChange', function () { + // console.log(iSlider.TRANSITION_END_EVENT, iSlider.BROWSER_PREFIX); + // }); // // islider.on('slideChanged', function () { // console.debug('Change(d) event from method "on"', this, arguments); diff --git a/src/js/ext/animate.js b/src/js/ext/animate.js index 7da7eb7d..facd3815 100644 --- a/src/js/ext/animate.js +++ b/src/js/ext/animate.js @@ -36,7 +36,7 @@ } } - this.wrap.style.webkitPerspective = scale * 4; + iSlider.setStyle(this.wrap, 'perspective', scale * 4); dom.style.visibility = 'visible'; if (direct > 0 && i === 2) { @@ -47,13 +47,13 @@ } dom.style.zIndex = i === 1 ? 1 : 0; - dom.style.cssText += '-webkit-backface-visibility:hidden; -webkit-transform-style:preserve-3d; position:absolute;'; + dom.style.cssText += iSlider.styleProp('backface-visibility') + ':hidden;' + iSlider.styleProp('transform-style') + ':preserve-3d;' + 'position:absolute;'; + // TODO: overflow... I dont understand why there are many differences between ios and desktop. Maybe they have different interpretations of Perspective - // dom.style.webkitTransform = 'rotate' + rotateDirect + '(' + 0.9153 * 90 * (offset / scale + i - 1) + 'deg) translateZ(' + ( scale / 2) + 'px) scale(0.875)'; - dom.style.webkitTransform = 'rotate' + rotateDirect + '(' + 90 * (offset / scale + i - 1) + 'deg) translateZ(' + (0.889 * scale / 2) + 'px) scale(0.889)'; + iSlider.setStyle(dom, 'transform', 'rotate' + rotateDirect + '(' + 90 * (offset / scale + i - 1) + 'deg) translateZ(' + (0.889 * scale / 2) + 'px) scale(0.889)'); } - rotate.effect = 'transform'; + rotate.effect = iSlider.styleProp('transform'); rotate.reverse = true; return rotate; })(), @@ -63,7 +63,8 @@ if (this.isVertical) { offset = -offset; } - this.wrap.style.webkitPerspective = scale * 4; + + iSlider.setStyle(this.wrap, 'perspective', scale * 4); dom.style.visibility = 'visible'; if (direct > 0 && i === 2) { @@ -73,11 +74,11 @@ dom.style.visibility = 'hidden'; } - dom.style.cssText += 'position:absolute; -webkit-backface-visibility:hidden;'; - dom.style.webkitTransform = 'translateZ(' + (scale / 2) + 'px) rotate' + ((axis === 'X') ? 'Y' : 'X') + '(' + 180 * (offset / scale + i - 1) + 'deg) scale(0.875)'; + dom.style.cssText += 'position:absolute;' + iSlider.styleProp('backface-visibility') + ':hidden'; + iSlider.setStyle(dom, 'transform', 'translateZ(' + (scale / 2) + 'px) rotate' + ((axis === 'X') ? 'Y' : 'X') + '(' + 180 * (offset / scale + i - 1) + 'deg) scale(0.875)'); } - flip.effect = 'transform'; + flip.effect = iSlider.styleProp('transform'); flip.reverse = true; return flip; })(), @@ -85,12 +86,12 @@ function depth(dom, axis, scale, i, offset, direct) { var zoomScale = (4 - Math.abs(i - 1)) * 0.18; - this.wrap.style.webkitPerspective = scale * 4; + iSlider.setStyle(this.wrap, 'perspective', scale * 4); dom.style.zIndex = i === 1 ? 1 : 0; - dom.style.webkitTransform = 'scale(' + zoomScale + ') translateZ(0) translate' + axis + '(' + (offset + 1.3 * scale * (i - 1)) + 'px)'; + iSlider.setStyle(dom, 'transform', 'scale(' + zoomScale + ') translateZ(0) translate' + axis + '(' + (offset + 1.3 * scale * (i - 1)) + 'px)'); } - depth.effect = 'transform'; + depth.effect = iSlider.styleProp('transform'); return depth; })(), flow: (function () { @@ -100,7 +101,7 @@ var directAmend = (axis === 'X') ? 1 : -1; var offsetRatio = Math.abs(offset / scale); - this.wrap.style.webkitPerspective = scale * 4; + iSlider.setStyle(this.wrap, 'perspective', scale * 4); if (i === 1) { dom.style.zIndex = scale - absoluteOffset; @@ -109,10 +110,10 @@ dom.style.zIndex = (offset > 0) ? (1 - i) * absoluteOffset : (i - 1) * absoluteOffset; } - dom.style.webkitTransform = 'scale(0.7, 0.7) translateZ(' + (offsetRatio * 150 - 150) * Math.abs(i - 1) + 'px)' + 'translate' + axis + '(' + (offset + scale * (i - 1)) + 'px)' + 'rotate' + rotateDirect + '(' + directAmend * (30 - offsetRatio * 30) * (1 - i) + 'deg)'; + iSlider.setStyle(dom, 'transform', 'scale(0.7, 0.7) translateZ(' + (offsetRatio * 150 - 150) * Math.abs(i - 1) + 'px)' + 'translate' + axis + '(' + (offset + scale * (i - 1)) + 'px)' + 'rotate' + rotateDirect + '(' + directAmend * (30 - offsetRatio * 30) * (1 - i) + 'deg)'); } - flow.effect = 'transform'; + flow.effect = iSlider.styleProp('transform'); return flow; })(), card: (function () { @@ -135,10 +136,10 @@ } } dom.style.zIndex = z; - dom.style.webkitTransform = 'scale(' + zoomScale + ') translateZ(0) translate' + axis + '(' + ((1 + Math.abs(i - 1) * 0.2) * offset + scale * (i - 1)) + 'px)'; + iSlider.setStyle(dom, 'transform', 'scale(' + zoomScale + ') translateZ(0) translate' + axis + '(' + ((1 + Math.abs(i - 1) * 0.2) * offset + scale * (i - 1)) + 'px)'); } - card.effect = 'transform'; + card.effect = iSlider.styleProp('transform'); return card; })(), fade: (function () { @@ -168,7 +169,7 @@ o = oa < 1 ? oa : 1; s = 2 - (0.5 * oa); z = 2; - var at = parseInt(window.getComputedStyle(dom).transitionDuration) * 1000; + var at = parseInt(window.getComputedStyle(dom)[iSlider.styleProp('transitionDuration', 1)]) * 1000; if (at > 0) { lsn = window.setTimeout(function () { dom.style.zIndex = 0; @@ -186,11 +187,9 @@ z = 0; break; } - dom.style.cssText += 'z-index:' + z + ';opacity:' + o + ';-webkit-transform: scale(' + s + ');'; + dom.style.cssText += 'z-index:' + z + ';opacity:' + o + ';' + iSlider.styleProp('transform') + ':scale(' + s + ');'; } - //what.effect = 'all'; - //what.effect = 'transform,opacity'; zoomout.reverse = true; return zoomout; })() diff --git a/src/js/iSlider.js b/src/js/iSlider.js index c78e5de5..9929541a 100644 --- a/src/js/iSlider.js +++ b/src/js/iSlider.js @@ -98,6 +98,12 @@ return Array.prototype.slice.apply(a, Array.prototype.slice.call(arguments, 1)); } + function IU(word) { + return word.replace(/^[a-z]/, function (t) { + return t.toUpperCase(); + }); + } + /** * @constructor * @@ -161,7 +167,7 @@ * version * @type {string} */ - iSlider.VERSION = '2.1.4'; + iSlider.VERSION = '2.1.5'; /** * Event white list @@ -223,23 +229,28 @@ * @returns {String} * @private */ - iSlider.TRANSITION_END_EVENT = (function () { - var el = document.createElement('fakeElement'); - var transitions = { - transition: 'transitionend', - OTransition: 'oTransitionEnd', - MozTransition: 'transitionend', - WebkitTransition: 'webkitTransitionEnd' - }; - for (var t in transitions) { - if (transitions.hasOwnProperty(t) && el.style[t] !== undefined) { - return transitions[t]; - } - } - - return null; + iSlider.TRANSITION_END_EVENT = null; + + iSlider.BROWSER_PREFIX = null; + + (function () { + var e = document.createElement('fakeElement'); + [ + ['WebkitTransition', 'webkitTransitionEnd', 'webkit'], + ['transition', 'transitionend', null], + ['MozTransition', 'transitionend', 'moz'], + ['OTransition', 'oTransitionEnd', 'o'] + ].some(function (t) { + if (e.style[t[0]] !== undefined) { + iSlider.TRANSITION_END_EVENT = t[1]; + iSlider.BROWSER_PREFIX = t[2]; + return true; + } + }); })(); + console.log(iSlider.TRANSITION_END_EVENT) + /** * Event match depending on the browser supported * @type {{hasTouch, startEvt, moveEvt, endEvt, cancelEvt, resizeEvt}} @@ -300,6 +311,44 @@ iSlider.plugins[name] = iSlider.plugins[name] || plugin; }; + /** + * @param {String} prop + * @param {String} value + * @returns {String} + * @public + */ + iSlider.styleProp = function (prop, isDP) { + if (iSlider.BROWSER_PREFIX) { + if (!!isDP) { + return iSlider.BROWSER_PREFIX + IU(prop); + } else { + return '-' + iSlider.BROWSER_PREFIX + '-' + prop; + } + } else { + return prop; + } + }; + + /** + * @param {String} prop + * @param {HTMLElement} dom + * @param {String} value + * @public + */ + iSlider.setStyle = function (dom, prop, value) { + dom.style[iSlider.styleProp(prop, 1)] = value; + }; + + /** + * @param {String} prop + * @param {HTMLElement} dom + * @param {String} value + * @public + */ + iSlider.getStyle = function (dom, prop) { + return dom.style[iSlider.styleProp(prop, 1)]; + }; + /** * @type {Object} * @@ -313,10 +362,10 @@ iSlider._animateFuncs = { normal: (function () { function normal(dom, axis, scale, i, offset) { - dom.style.webkitTransform = 'translateZ(0) translate' + axis + '(' + (offset + scale * (i - 1)) + 'px)'; + iSlider.setStyle(dom, 'transform', 'translateZ(0) translate' + axis + '(' + (offset + scale * (i - 1)) + 'px)'); } - normal.effect = 'transform'; + normal.effect = iSlider.styleProp('transform'); return normal; })() }; @@ -1025,9 +1074,8 @@ this.currentEl.addEventListener(iSlider.TRANSITION_END_EVENT, cb); // keep handler and element this._transitionEndHandler = {el: this.currentEl, handler: cb}; - } else { - this._LSN.transitionEnd = global.setTimeout(cb, squeezeTime); } + this._LSN.transitionEnd = global.setTimeout(cb, squeezeTime); }; /** @@ -1192,7 +1240,7 @@ this.els.forEach(function (item, i) { item.style.visibility = 'visible'; - item.style.webkitTransition = 'none'; + iSlider.setStyle(item, 'transition', 'none'); this._animateFunc(item, axis, this.scale, i, offset[axis], offset[axis]); this.fillSeam && this.seamScale(item); }.bind(this)); @@ -1406,7 +1454,7 @@ this._intermediateScene = [tailEl, idx - direction]; } - headEl.style.webkitTransition = 'none'; + iSlider.setStyle(headEl, 'transition', 'none'); // Minus squeeze time squeezeTime = animateTime - squeezeTime; @@ -1429,7 +1477,7 @@ for (var i = 0; i < 3; i++) { if (els[i] !== headEl) { // Only applies their effects - els[i].style.webkitTransition = (animateFunc.effect || 'all') + ' ' + squeezeTime + 'ms ' + this.animateEasing; + iSlider.setStyle(els[i], 'transition', (animateFunc.effect || 'all') + ' ' + squeezeTime + 'ms ' + this.animateEasing); } animateFunc.call(this, els[i], axis, this.scale, i, 0, direction); this.fillSeam && this.seamScale(els[i]); @@ -1787,8 +1835,9 @@ */ iSliderPrototype.seamScale = function (el) { var regex = /scale([XY]?)\(([^\)]+)\)/; - if (regex.test(el.style.webkitTransform)) { - el.style.webkitTransform = el.style.webkitTransform.replace(regex, function (res, axis, scale) { + var transformStyle = iSlider.getStyle(el, 'transform'); + if (regex.test(transformStyle)) { + iSlider.setStyle(el, 'transform', transformStyle.replace(regex, function (res, axis, scale) { var sc = {}; if (axis) { sc[axis] = parseFloat(scale); @@ -1804,9 +1853,9 @@ sc[this.axis] *= 1.001; return 'scale(' + sc.X + ', ' + sc.Y + ')'; } - }.bind(this)); + }.bind(this))); } else { - el.style.webkitTransform += 'scale' + this.axis + '(1.001)'; + iSlider.setStyle(el, 'transform', transformStyle + ' scale' + this.axis + '(1.001)'); } }; @@ -1816,7 +1865,7 @@ */ iSliderPrototype.originScale = function (el) { var regex = /([\x20]?scale)([XY]?)\(([^\)]+)\)/; - el.style.webkitTransform = el.style.webkitTransform.replace(regex, function (sc, res, axis, scale) { + iSlider.setStyle(el, 'transform', iSlider.getStyle(el, 'transform').replace(regex, function (sc, res, axis, scale) { sc = {}; if (axis) { if (scale === '1.001') { @@ -1836,7 +1885,7 @@ sc[this.axis] /= 1.001; return 'scale(' + sc.X + ', ' + sc.Y + ')'; } - }.bind(this)); + }.bind(this))); }; diff --git a/src/style/iSlider.css b/src/style/iSlider.css index abc85222..4235cc1e 100755 --- a/src/style/iSlider.css +++ b/src/style/iSlider.css @@ -28,9 +28,13 @@ height: 100%; list-style: none; overflow: hidden; + display: -moz-box; display: -webkit-box; + display: box; + -moz-box-pack: center; -webkit-box-pack: center; box-pack: center; + -moz-box-align: center; -webkit-box-align: center; box-align: center; } @@ -88,11 +92,17 @@ .islider-btn-outer.left > .islider-btn-inner { -webkit-transform: rotate(-45deg); + -moz-transform: rotate(-45deg); + -ms-transform: rotate(-45deg); + -o-transform: rotate(-45deg); transform: rotate(-45deg); } .islider-btn-outer.right > .islider-btn-inner { -webkit-transform: rotate(135deg); + -moz-transform: rotate(135deg); + -ms-transform: rotate(135deg); + -o-transform: rotate(135deg); transform: rotate(135deg); } From 9b0c228017482015b25e3b70d20bfedd49bf555d Mon Sep 17 00:00:00 2001 From: shinate Date: Sat, 19 Mar 2016 15:28:15 +0800 Subject: [PATCH 8/9] changelog --- change_log.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/change_log.md b/change_log.md index 954e3885..92b975be 100644 --- a/change_log.md +++ b/change_log.md @@ -1,5 +1,7 @@ ### iSlider 2.1.5 - [New]Add method "[pushData](https://github.com/BE-FE/iSlider/blob/master/README.md#pushdata)", now you can append data dynamically. Here is the [DEMO](http://be-fe.github.io/iSlider/demo/add_dynamic_data.html). +- [Optimization][Bug fix]Android browser (including wechat) failures of transition. +- [Optimization]Support Firefox browser, UC browser. ### iSlider 2.1.4 - [Optimization]Options fixPage support policy "exclusion list", it allows you to trigger default event for the specific element. From 140f0ea84f3b946f3e51d76a49ca3c848f6a3a7d Mon Sep 17 00:00:00 2001 From: shinate Date: Sat, 19 Mar 2016 15:34:52 +0800 Subject: [PATCH 9/9] changelog modified --- change_log.md | 1 + 1 file changed, 1 insertion(+) diff --git a/change_log.md b/change_log.md index 92b975be..1d40d1df 100644 --- a/change_log.md +++ b/change_log.md @@ -2,6 +2,7 @@ - [New]Add method "[pushData](https://github.com/BE-FE/iSlider/blob/master/README.md#pushdata)", now you can append data dynamically. Here is the [DEMO](http://be-fe.github.io/iSlider/demo/add_dynamic_data.html). - [Optimization][Bug fix]Android browser (including wechat) failures of transition. - [Optimization]Support Firefox browser, UC browser. +- [Bug fix]Firefox Android browser and certain "slideChanged", "slideRestored" event failures. ### iSlider 2.1.4 - [Optimization]Options fixPage support policy "exclusion list", it allows you to trigger default event for the specific element.