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..248e1164 100644
--- a/README_Chinese.md
+++ b/README_Chinese.md
@@ -673,6 +673,14 @@ S.on('slideChanged', callBack);
- 载入新的数据列表
- 参数:
- `{Array}` 数据列表
+ - `{Number}` 初始场景索引
+
+
+#### pushData
+
+- 追加数据到已有的数据序列末尾
+- 参数:
+ - `{Array|Object}` 一个成员或者追加的序列(数组)
#### subjectTo
diff --git a/bower.json b/bower.json
index 62fac4d3..013ab16a 100644
--- a/bower.json
+++ b/bower.json
@@ -41,5 +41,5 @@
"index.html",
"gulp"
],
- "version": "2.1.4"
+ "version": "2.1.5"
}
diff --git a/build/iSlider.animate.js b/build/iSlider.animate.js
index 7da7eb7d..facd3815 100644
--- a/build/iSlider.animate.js
+++ b/build/iSlider.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/build/iSlider.animate.min.js b/build/iSlider.animate.min.js
index d2928b06..30a42fbc 100644
--- a/build/iSlider.animate.min.js
+++ b/build/iSlider.animate.min.js
@@ -1 +1 @@
-!function(e,t){"function"==typeof require&&"object"==typeof module&&module&&"object"==typeof exports&&exports?t(require("iSlider")):"function"==typeof define&&define.amd?define(["iSlider"],function(e){t(e)}):t(e.iSlider)}(window?window:this,function(e){"use strict";e&&e.extend(e._animateFuncs,{rotate:function(){function e(e,t,i,s,n,a){var r="X"===t?"Y":"X";this.isVertical&&(n=-n,Math.abs(a)>1&&(a=-a)),this.wrap.style.webkitPerspective=4*i,e.style.visibility="visible",a>0&&2===s&&(e.style.visibility="hidden"),0>a&&0===s&&(e.style.visibility="hidden"),e.style.zIndex=1===s?1:0,e.style.cssText+="-webkit-backface-visibility:hidden; -webkit-transform-style:preserve-3d; position:absolute;",e.style.webkitTransform="rotate"+r+"("+90*(n/i+s-1)+"deg) translateZ("+.889*i/2+"px) scale(0.889)"}return e.effect="transform",e.reverse=!0,e}(),flip:function(){function e(e,t,i,s,n,a){this.isVertical&&(n=-n),this.wrap.style.webkitPerspective=4*i,e.style.visibility="visible",a>0&&2===s&&(e.style.visibility="hidden"),0>a&&0===s&&(e.style.visibility="hidden"),e.style.cssText+="position:absolute; -webkit-backface-visibility:hidden;",e.style.webkitTransform="translateZ("+i/2+"px) rotate"+("X"===t?"Y":"X")+"("+180*(n/i+s-1)+"deg) scale(0.875)"}return e.effect="transform",e.reverse=!0,e}(),depth:function(){function e(e,t,i,s,n,a){var r=.18*(4-Math.abs(s-1));this.wrap.style.webkitPerspective=4*i,e.style.zIndex=1===s?1:0,e.style.webkitTransform="scale("+r+") translateZ(0) translate"+t+"("+(n+1.3*i*(s-1))+"px)"}return e.effect="transform",e}(),flow:function(){function e(e,t,i,s,n,a){var r=Math.abs(n),o="X"===t?"Y":"X",l="X"===t?1:-1,c=Math.abs(n/i);this.wrap.style.webkitPerspective=4*i,1===s?e.style.zIndex=i-r:e.style.zIndex=n>0?(1-s)*r:(s-1)*r,e.style.webkitTransform="scale(0.7, 0.7) translateZ("+(150*c-150)*Math.abs(s-1)+"px)translate"+t+"("+(n+i*(s-1))+"px)rotate"+o+"("+l*(30-30*c)*(1-s)+"deg)"}return e.effect="transform",e}(),card:function(){function e(e,t,i,s,n,a){var r=Math.abs(n),o=1,l=1;r>0?1===s&&(o=1-.2*Math.abs(s-1)-Math.abs(.2*n/i).toFixed(6),l=0):1!==s&&((a>0&&0===s||0>a&&2===s)&&(o=1-.2*Math.abs(s-1)),l=0),e.style.zIndex=l,e.style.webkitTransform="scale("+o+") translateZ(0) translate"+t+"("+((1+.2*Math.abs(s-1))*n+i*(s-1))+"px)"}return e.effect="transform",e}(),fade:function(){function e(e,t,i,s,n,a){e.style.zIndex=1===s?1:0,n=Math.abs(n),1===s?e.style.opacity=1-n/i:e.style.opacity=n/i}return e.effect="opacity",e}(),zoomout:function(){function e(e,i,s,n,a){var r,o,l,c=a/s;switch(n){case 0:t&&window.clearTimeout(t),o=1>c?c:1,l=2-.5*c,r=2;var f=1e3*parseInt(window.getComputedStyle(e).transitionDuration);f>0&&(t=window.setTimeout(function(){e.style.zIndex=0},f));break;case 1:o=1-c,l=1-.5*c,r=1;break;case 2:o=c>0?c:0,l=.5-.5*c,r=0}e.style.cssText+="z-index:"+r+";opacity:"+o+";-webkit-transform: scale("+l+");"}var t;return e.reverse=!0,e}()})});
\ No newline at end of file
+!function(t,e){"function"==typeof require&&"object"==typeof module&&module&&"object"==typeof exports&&exports?e(require("iSlider")):"function"==typeof define&&define.amd?define(["iSlider"],function(t){e(t)}):e(t.iSlider)}(window?window:this,function(t){"use strict";t&&t.extend(t._animateFuncs,{rotate:function(){function e(e,s,i,r,n,a){var o="X"===s?"Y":"X";this.isVertical&&(n=-n,Math.abs(a)>1&&(a=-a)),t.setStyle(this.wrap,"perspective",4*i),e.style.visibility="visible",a>0&&2===r&&(e.style.visibility="hidden"),0>a&&0===r&&(e.style.visibility="hidden"),e.style.zIndex=1===r?1:0,e.style.cssText+=t.styleProp("backface-visibility")+":hidden;"+t.styleProp("transform-style")+":preserve-3d;position:absolute;",t.setStyle(e,"transform","rotate"+o+"("+90*(n/i+r-1)+"deg) translateZ("+.889*i/2+"px) scale(0.889)")}return e.effect=t.styleProp("transform"),e.reverse=!0,e}(),flip:function(){function e(e,s,i,r,n,a){this.isVertical&&(n=-n),t.setStyle(this.wrap,"perspective",4*i),e.style.visibility="visible",a>0&&2===r&&(e.style.visibility="hidden"),0>a&&0===r&&(e.style.visibility="hidden"),e.style.cssText+="position:absolute;"+t.styleProp("backface-visibility")+":hidden",t.setStyle(e,"transform","translateZ("+i/2+"px) rotate"+("X"===s?"Y":"X")+"("+180*(n/i+r-1)+"deg) scale(0.875)")}return e.effect=t.styleProp("transform"),e.reverse=!0,e}(),depth:function(){function e(e,s,i,r,n,a){var o=.18*(4-Math.abs(r-1));t.setStyle(this.wrap,"perspective",4*i),e.style.zIndex=1===r?1:0,t.setStyle(e,"transform","scale("+o+") translateZ(0) translate"+s+"("+(n+1.3*i*(r-1))+"px)")}return e.effect=t.styleProp("transform"),e}(),flow:function(){function e(e,s,i,r,n,a){var o=Math.abs(n),l="X"===s?"Y":"X",c="X"===s?1:-1,f=Math.abs(n/i);t.setStyle(this.wrap,"perspective",4*i),1===r?e.style.zIndex=i-o:e.style.zIndex=n>0?(1-r)*o:(r-1)*o,t.setStyle(e,"transform","scale(0.7, 0.7) translateZ("+(150*f-150)*Math.abs(r-1)+"px)translate"+s+"("+(n+i*(r-1))+"px)rotate"+l+"("+c*(30-30*f)*(1-r)+"deg)")}return e.effect=t.styleProp("transform"),e}(),card:function(){function e(e,s,i,r,n,a){var o=Math.abs(n),l=1,c=1;o>0?1===r&&(l=1-.2*Math.abs(r-1)-Math.abs(.2*n/i).toFixed(6),c=0):1!==r&&((a>0&&0===r||0>a&&2===r)&&(l=1-.2*Math.abs(r-1)),c=0),e.style.zIndex=c,t.setStyle(e,"transform","scale("+l+") translateZ(0) translate"+s+"("+((1+.2*Math.abs(r-1))*n+i*(r-1))+"px)")}return e.effect=t.styleProp("transform"),e}(),fade:function(){function t(t,e,s,i,r,n){t.style.zIndex=1===i?1:0,r=Math.abs(r),1===i?t.style.opacity=1-r/s:t.style.opacity=r/s}return t.effect="opacity",t}(),zoomout:function(){function e(e,i,r,n,a){var o,l,c,f=a/r;switch(n){case 0:s&&window.clearTimeout(s),l=1>f?f:1,c=2-.5*f,o=2;var y=1e3*parseInt(window.getComputedStyle(e)[t.styleProp("transitionDuration",1)]);y>0&&(s=window.setTimeout(function(){e.style.zIndex=0},y));break;case 1:l=1-f,c=1-.5*f,o=1;break;case 2:l=f>0?f:0,c=.5-.5*f,o=0}e.style.cssText+="z-index:"+o+";opacity:"+l+";"+t.styleProp("transform")+":scale("+c+");"}var s;return e.reverse=!0,e}()})});
\ No newline at end of file
diff --git a/build/iSlider.css b/build/iSlider.css
index abc85222..4235cc1e 100755
--- a/build/iSlider.css
+++ b/build/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);
}
diff --git a/build/iSlider.js b/build/iSlider.js
index 58ca207b..9929541a 100644
--- a/build/iSlider.js
+++ b/build/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]);
@@ -1677,7 +1725,10 @@
};
/**
- * reload Data & render
+ * Reload Data & render
+ *
+ * @param {Array} data
+ * @param {Number} initIndex
* @public
*/
iSliderPrototype.loadData = function (data, initIndex) {
@@ -1690,6 +1741,27 @@
this.fire('loadData slideChanged', this.slideIndex, this.currentEl, this);
};
+ /**
+ * Add scenes to the end of the data datasheets
+ *
+ * @param {Object|Array} sceneData
+ * @description
+ * Object:
+ * {content:...}
+ * Array:
+ * [{content:...}, {content:...}, ...]
+ */
+ iSliderPrototype.pushData = function (sceneData) {
+ var len = this.data.length;
+ this.data = this.data.concat(sceneData);
+ 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
+ }
+ };
+
/**
* auto check to play and bind events
* @private
@@ -1763,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);
@@ -1780,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)');
}
};
@@ -1792,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') {
@@ -1812,7 +1885,7 @@
sc[this.axis] /= 1.001;
return 'scale(' + sc.X + ', ' + sc.Y + ')';
}
- }.bind(this));
+ }.bind(this)));
};
diff --git a/build/iSlider.min.css b/build/iSlider.min.css
index 4edc53da..8f88e25a 100755
--- a/build/iSlider.min.css
+++ b/build/iSlider.min.css
@@ -1 +1 @@
-.islider-outer,.islider-outer>li{margin:0;width:100%;height:100%;overflow:hidden;padding:0;list-style:none}.islider-outer{display:block;position:relative}.islider-outer>li{position:absolute;top:0;left:0;display:-webkit-box;-webkit-box-pack:center;box-pack:center;-webkit-box-align:center;box-align:center}.islider-img>img{max-width:100%;max-height:100%}.islider-sliding{z-index:0}.islider-sliding-focus{z-index:1}.islider-btn-outer{position:absolute;width:3em;height:3em;cursor:pointer;top:0;bottom:0;margin:auto 0;display:block;background-color:#777}.islider-btn-outer.left{left:5%}.islider-btn-outer.right{right:5%}.islider-btn-inner,.islider-dot-wrap{position:absolute;left:0;right:0;bottom:0}.islider-btn-inner{width:50%;height:50%;border-top:2px solid #fff;border-left:2px solid #fff;margin:auto;top:0}.islider-btn-outer.left>.islider-btn-inner{-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.islider-btn-outer.right>.islider-btn-inner{-webkit-transform:rotate(135deg);transform:rotate(135deg)}.islider-dot-wrap{width:80%;height:10%;margin:0 auto;padding:0;z-index:10000;text-align:center}.islider-dot{position:relative;display:inline-block;width:.8em;height:.8em;border-radius:50%;border:1px solid #fff;list-style:none;margin:5px}.islider-dot.active{background-color:#fff}
\ No newline at end of file
+.islider-outer,.islider-outer>li{margin:0;width:100%;height:100%;overflow:hidden;padding:0;list-style:none}.islider-outer{display:block;position:relative}.islider-outer>li{position:absolute;top:0;left:0;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}.islider-img>img{max-width:100%;max-height:100%}.islider-sliding{z-index:0}.islider-sliding-focus{z-index:1}.islider-btn-outer{position:absolute;width:3em;height:3em;cursor:pointer;top:0;bottom:0;margin:auto 0;display:block;background-color:#777}.islider-btn-outer.left{left:5%}.islider-btn-outer.right{right:5%}.islider-btn-inner,.islider-dot-wrap{position:absolute;left:0;right:0;bottom:0}.islider-btn-inner{width:50%;height:50%;border-top:2px solid #fff;border-left:2px solid #fff;margin:auto;top:0}.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)}.islider-dot-wrap{width:80%;height:10%;margin:0 auto;padding:0;z-index:10000;text-align:center}.islider-dot{position:relative;display:inline-block;width:.8em;height:.8em;border-radius:50%;border:1px solid #fff;list-style:none;margin:5px}.islider-dot.active{background-color:#fff}
\ No newline at end of file
diff --git a/build/iSlider.min.js b/build/iSlider.min.js
index c6378c8c..c2acc36b 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])Animation Effects
+
demo code
@@ -861,6 +862,17 @@ loadData
+ pushData
+
+
+
+
+
+ {Array|Object}
A member or additional datasheetssubjectTo
diff --git a/demo/index_chinese.html b/demo/index_chinese.html
index 89bfd058..59ae3389 100755
--- a/demo/index_chinese.html
+++ b/demo/index_chinese.html
@@ -202,7 +202,8 @@
动画效果
-
+
+
demo代码
@@ -860,6 +861,18 @@
loadData
+ {Array}
数据列表{Number}
初始场景索引pushData
+
+
+
diff --git a/demo/public/css/iSlider.css b/demo/public/css/iSlider.css
index abc85222..4235cc1e 100755
--- a/demo/public/css/iSlider.css
+++ b/demo/public/css/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);
}
diff --git a/demo/public/js/iSlider.animate.js b/demo/public/js/iSlider.animate.js
index 7da7eb7d..facd3815 100644
--- a/demo/public/js/iSlider.animate.js
+++ b/demo/public/js/iSlider.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/demo/public/js/iSlider.js b/demo/public/js/iSlider.js
index 58ca207b..9929541a 100644
--- a/demo/public/js/iSlider.js
+++ b/demo/public/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]);
@@ -1677,7 +1725,10 @@
};
/**
- * reload Data & render
+ * Reload Data & render
+ *
+ * @param {Array} data
+ * @param {Number} initIndex
* @public
*/
iSliderPrototype.loadData = function (data, initIndex) {
@@ -1690,6 +1741,27 @@
this.fire('loadData slideChanged', this.slideIndex, this.currentEl, this);
};
+ /**
+ * Add scenes to the end of the data datasheets
+ *
+ * @param {Object|Array} sceneData
+ * @description
+ * Object:
+ * {content:...}
+ * Array:
+ * [{content:...}, {content:...}, ...]
+ */
+ iSliderPrototype.pushData = function (sceneData) {
+ var len = this.data.length;
+ this.data = this.data.concat(sceneData);
+ 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
+ }
+ };
+
/**
* auto check to play and bind events
* @private
@@ -1763,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);
@@ -1780,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)');
}
};
@@ -1792,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') {
@@ -1812,7 +1885,7 @@
sc[this.axis] /= 1.001;
return 'scale(' + sc.X + ', ' + sc.Y + ')';
}
- }.bind(this));
+ }.bind(this)));
};
diff --git a/package.json b/package.json
index ce29c5a0..aff942a2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "islider.js",
- "version": "2.1.4",
+ "version": "2.1.5",
"author": "EUX team",
"main": "build/iSlider.min.js",
"description": "Smooth and high-performance slide web framework. Suitable for PC, Mobile WebApp, HTML5 App, Hybrid App",
@@ -10,6 +10,7 @@
"gulp": "^3.9.1",
"gulp-clean": "^0.3.1",
"gulp-cssmin": "^0.1.7",
+ "gulp-livereload": "^3.8.1",
"gulp-load-plugins": "^1.2.0",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.5.1",
diff --git a/src/index.html b/src/index.html
index d9b3a2d7..611b0d8a 100644
--- a/src/index.html
+++ b/src/index.html
@@ -74,6 +74,7 @@
src="https://cloud.githubusercontent.com/assets/8253888/10995507/592ce796-84b8-11e5-842b-938c55a4cb3a.jpg"
alt="qq 20151106184244" style="max-width:100%;">
+
{Array|Object}
一个成员或者追加的序列(数组)