@dolphinweex/weex-vue-render 0.2.19 → 0.2.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.common.js +112 -97
- package/package.json +1 -1
package/dist/index.common.js
CHANGED
|
@@ -3463,12 +3463,15 @@ function applySrc (item, src, placeholderSrc) {
|
|
|
3463
3463
|
if (item._src_loading === src) {
|
|
3464
3464
|
return
|
|
3465
3465
|
}
|
|
3466
|
-
|
|
3466
|
+
function isEncoded(url) { //检查 % 后是否是合法的编码
|
|
3467
|
+
return /%[0-9A-Fa-f]{2}/.test(url);
|
|
3468
|
+
}
|
|
3467
3469
|
/**
|
|
3468
3470
|
* 1. apply src immediately in case javscript blocks the image loading
|
|
3469
3471
|
* before next tick.
|
|
3470
3472
|
*/
|
|
3471
|
-
|
|
3473
|
+
const finalUrl = isEncoded(src) ? src : encodeURI(src);
|
|
3474
|
+
item.style.backgroundImage = "url(" + (src ? finalUrl : '') + ")";
|
|
3472
3475
|
item.removeAttribute(lazyloadAttr);
|
|
3473
3476
|
/**
|
|
3474
3477
|
* 2. then load the img src with Image constructor (but would not post
|
|
@@ -3476,7 +3479,8 @@ function applySrc (item, src, placeholderSrc) {
|
|
|
3476
3479
|
*/
|
|
3477
3480
|
item._src_loading = src;
|
|
3478
3481
|
preLoadImg(src, function (evt) {
|
|
3479
|
-
|
|
3482
|
+
const finalUrl = isEncoded(src) ? src : encodeURI(src);
|
|
3483
|
+
item.style.backgroundImage = "url(" + (src ? finalUrl : '') + ")";
|
|
3480
3484
|
var ref = this;
|
|
3481
3485
|
var naturalWidth = ref.width;
|
|
3482
3486
|
var naturalHeight = ref.height;
|
|
@@ -3493,8 +3497,9 @@ function applySrc (item, src, placeholderSrc) {
|
|
|
3493
3497
|
};
|
|
3494
3498
|
dispatchNativeEvent(item, 'load', params);
|
|
3495
3499
|
if (placeholderSrc) {
|
|
3500
|
+
const finalUrl = isEncoded(placeholderSrc) ? placeholderSrc : encodeURI(placeholderSrc);
|
|
3496
3501
|
preLoadImg(placeholderSrc, function () {
|
|
3497
|
-
item.style.backgroundImage = "url(" + (placeholderSrc ?
|
|
3502
|
+
item.style.backgroundImage = "url(" + (placeholderSrc ? finalUrl : '') + ")";
|
|
3498
3503
|
});
|
|
3499
3504
|
}
|
|
3500
3505
|
finallCb();
|
|
@@ -5059,6 +5064,7 @@ var inputCommon = {
|
|
|
5059
5064
|
methods: {
|
|
5060
5065
|
focus: function focus () {
|
|
5061
5066
|
this.$el && this.$el.focus();
|
|
5067
|
+
this.$el && weex.requireModule('bridgeModule').commandInterface(JSON.stringify({ operation: 'showKeyboard'}))
|
|
5062
5068
|
},
|
|
5063
5069
|
blur: function blur () {
|
|
5064
5070
|
this.$el && this.$el.blur();
|
|
@@ -7400,6 +7406,7 @@ var slideMixin = {
|
|
|
7400
7406
|
this._clones = [];
|
|
7401
7407
|
this.innerOffset = 0;
|
|
7402
7408
|
this._indicator = null;
|
|
7409
|
+
this.cloneIndex = Boolean(this.infinite) //需要减或者加去克隆下标
|
|
7403
7410
|
},
|
|
7404
7411
|
|
|
7405
7412
|
beforeUpdate: function beforeUpdate () {
|
|
@@ -7455,7 +7462,7 @@ var slideMixin = {
|
|
|
7455
7462
|
|
|
7456
7463
|
mounted: function mounted () {
|
|
7457
7464
|
this._getWrapperSize();
|
|
7458
|
-
this._slideTo(this.currentIndex);
|
|
7465
|
+
this._slideTo(this.currentIndex + this.cloneIndex);
|
|
7459
7466
|
weex.utils.fireLazyload(this.$el, true);
|
|
7460
7467
|
},
|
|
7461
7468
|
|
|
@@ -7487,10 +7494,35 @@ var slideMixin = {
|
|
|
7487
7494
|
staticClass: ("weex-slider-cell weex-ct" + (this$1.isNeighbor ? ' neighbor-cell' : ''))
|
|
7488
7495
|
}, [vnode])
|
|
7489
7496
|
});
|
|
7497
|
+
|
|
7498
|
+
if (this.infinite && cells.length > 1) {
|
|
7499
|
+
// 克隆第一个和最后一个有效节点
|
|
7500
|
+
const cloneFirst = () => {
|
|
7501
|
+
const first = cells[0];
|
|
7502
|
+
return first ? createElement('li', {
|
|
7503
|
+
staticClass: "weex-slider-cell weex-ct clone-cell",
|
|
7504
|
+
key: 'clone-first'
|
|
7505
|
+
}, [first.children || first.componentOptions.children]) : null
|
|
7506
|
+
};
|
|
7507
|
+
|
|
7508
|
+
const cloneLast = () => {
|
|
7509
|
+
const last = cells[cells.length - 1];
|
|
7510
|
+
return last ? createElement('li', {
|
|
7511
|
+
staticClass: "weex-slider-cell weex-ct clone-cell",
|
|
7512
|
+
key: 'clone-last'
|
|
7513
|
+
}, [last.children || last.componentOptions.children]) : null
|
|
7514
|
+
};
|
|
7515
|
+
const lastClone = cloneLast();
|
|
7516
|
+
const firstClone = cloneFirst();
|
|
7517
|
+
|
|
7518
|
+
if (firstClone && lastClone) {
|
|
7519
|
+
cells = [lastClone].concat(cells).concat([firstClone]);
|
|
7520
|
+
}
|
|
7521
|
+
}
|
|
7490
7522
|
if (indicatorVnode) {
|
|
7491
7523
|
indicatorVnode.data.attrs = indicatorVnode.data.attrs || {};
|
|
7492
|
-
indicatorVnode.data.attrs.count = cells.length;
|
|
7493
|
-
indicatorVnode.data.attrs.active = this.currentIndex;
|
|
7524
|
+
indicatorVnode.data.attrs.count = cells.length - (this.infinite ? 2 : 0 ); // 显示实际数量
|
|
7525
|
+
indicatorVnode.data.attrs.active = this.currentIndex - this.cloneIndex;
|
|
7494
7526
|
this._indicator = indicatorVnode;
|
|
7495
7527
|
}
|
|
7496
7528
|
return cells
|
|
@@ -7549,55 +7581,77 @@ var slideMixin = {
|
|
|
7549
7581
|
}
|
|
7550
7582
|
},
|
|
7551
7583
|
|
|
7552
|
-
_slideTo: function _slideTo
|
|
7584
|
+
_slideTo: function _slideTo(index, isTouchScroll) {
|
|
7553
7585
|
var this$1 = this;
|
|
7554
|
-
|
|
7586
|
+
|
|
7555
7587
|
if (this.frameCount <= 0) {
|
|
7556
|
-
return
|
|
7588
|
+
return;
|
|
7557
7589
|
}
|
|
7558
7590
|
if (!this.infinite || this.infinite === 'false') {
|
|
7559
7591
|
if (index === -1 || index > (this.frameCount - 1)) {
|
|
7560
7592
|
this._slideTo(this.currentIndex);
|
|
7561
|
-
return
|
|
7593
|
+
return;
|
|
7562
7594
|
}
|
|
7563
7595
|
}
|
|
7564
7596
|
if (!this._preIndex && this._preIndex !== 0) {
|
|
7565
|
-
|
|
7566
|
-
this._preIndex = this._showNodes[0].index;
|
|
7567
|
-
}
|
|
7568
|
-
else {
|
|
7569
|
-
this._preIndex = 0;
|
|
7570
|
-
}
|
|
7597
|
+
this._preIndex = this.currentIndex || 0;
|
|
7571
7598
|
}
|
|
7572
|
-
|
|
7599
|
+
|
|
7573
7600
|
if (this._sliding) {
|
|
7574
|
-
return
|
|
7601
|
+
return;
|
|
7575
7602
|
}
|
|
7576
7603
|
this._sliding = true;
|
|
7577
|
-
|
|
7604
|
+
|
|
7578
7605
|
var newIndex = this._normalizeIndex(index);
|
|
7579
7606
|
var inner = this.$refs.inner;
|
|
7580
7607
|
var step = this._step = this.frameCount <= 1 ? 0 : this._preIndex - index;
|
|
7581
|
-
|
|
7608
|
+
|
|
7582
7609
|
if (inner) {
|
|
7583
7610
|
this._prepareNodes();
|
|
7584
7611
|
var translate = weex.utils.getTransformObj(inner).translate;
|
|
7585
7612
|
var match = translate && translate.match(/translate[^(]+\(([+-\d.]+)/);
|
|
7586
|
-
var innerX = parseFloat(inner.style.left);
|
|
7587
|
-
var dist = innerX - this.innerOffset + step;
|
|
7613
|
+
var innerX = parseFloat(inner.style.left);
|
|
7614
|
+
var dist = innerX - this.innerOffset + step;
|
|
7588
7615
|
this.innerOffset += step * this._wrapperWidth;
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7616
|
+
|
|
7617
|
+
// 克隆处理:先执行正常动画到克隆的最后一张,再瞬间跳回真实的第一张
|
|
7618
|
+
if (this.infinite && index >= this.frameCount - 1) {
|
|
7619
|
+
// 先滑到克隆的 `第一张`
|
|
7620
|
+
newIndex = this.frameCount - 1;
|
|
7621
|
+
this.innerOffset = -newIndex * this._wrapperWidth;
|
|
7622
|
+
inner.style.transition = `left ${TRANSITION_TIME / 1000}s ease-in-out`;
|
|
7623
|
+
inner.style.left = `${this.innerOffset}px`;
|
|
7624
|
+
newIndex = 1; // 视觉上显示 `第一张`
|
|
7625
|
+
|
|
7626
|
+
// 等待动画完成后瞬间跳到 `第一张`
|
|
7627
|
+
setTimeout(() => {
|
|
7628
|
+
inner.style.transition = 'none';
|
|
7629
|
+
this.innerOffset = -this._wrapperWidth; // 瞬间跳到 `第一张`
|
|
7630
|
+
inner.style.left = `${this.innerOffset}px`;
|
|
7631
|
+
}, TRANSITION_TIME);
|
|
7632
|
+
} else if (this.infinite && index <= 0) {
|
|
7633
|
+
// 先滑到克隆的 `最后一张`
|
|
7634
|
+
newIndex = 0;
|
|
7635
|
+
this.innerOffset = -newIndex * this._wrapperWidth;
|
|
7636
|
+
inner.style.transition = `left ${TRANSITION_TIME / 1000}s ease-in-out`;
|
|
7637
|
+
inner.style.left = `${this.innerOffset}px`;
|
|
7638
|
+
newIndex = this.frameCount - 2; // 视觉上显示 `最后一张`
|
|
7639
|
+
|
|
7640
|
+
// 等待动画完成后瞬间跳到 `最后一张`
|
|
7641
|
+
setTimeout(() => {
|
|
7642
|
+
inner.style.transition = 'none';
|
|
7643
|
+
this.innerOffset = -(this.frameCount - 2) * this._wrapperWidth; // 瞬间跳到 `最后一张`
|
|
7644
|
+
inner.style.left = `${this.innerOffset}px`;
|
|
7645
|
+
}, TRANSITION_TIME);
|
|
7646
|
+
|
|
7647
|
+
} else {
|
|
7648
|
+
// 正常切换
|
|
7649
|
+
this.innerOffset = -newIndex * this._wrapperWidth;
|
|
7650
|
+
inner.style.transition = `left ${TRANSITION_TIME / 1000}s ease-in-out`;
|
|
7651
|
+
inner.style.left = `${this.innerOffset}px`;
|
|
7652
|
+
}
|
|
7653
|
+
|
|
7654
|
+
// 触发事件
|
|
7601
7655
|
if (!isTouchScroll) {
|
|
7602
7656
|
this._emitScrollEvent('scrollstart');
|
|
7603
7657
|
}
|
|
@@ -7606,40 +7660,42 @@ var slideMixin = {
|
|
|
7606
7660
|
this$1._emitScrollEvent('scrollend');
|
|
7607
7661
|
});
|
|
7608
7662
|
}, THROTTLE_SCROLL_TIME);
|
|
7609
|
-
|
|
7663
|
+
|
|
7610
7664
|
this._loopShowNodes(step);
|
|
7611
|
-
|
|
7665
|
+
|
|
7612
7666
|
setTimeout(function () {
|
|
7613
7667
|
if (this$1.isNeighbor) {
|
|
7614
7668
|
this$1._setNeighbors();
|
|
7615
7669
|
}
|
|
7616
|
-
|
|
7670
|
+
|
|
7617
7671
|
setTimeout(function () {
|
|
7618
7672
|
inner.style.webkitTransition = '';
|
|
7619
7673
|
inner.style.mozTransition = '';
|
|
7620
7674
|
inner.style.transition = '';
|
|
7621
7675
|
for (var i = this$1._showStartIdx; i <= this$1._showEndIdx; i++) {
|
|
7622
7676
|
var node = this$1._showNodes[i];
|
|
7623
|
-
if (!node) {
|
|
7677
|
+
if (!node) {continue;}
|
|
7624
7678
|
var elm = node.firstElementChild;
|
|
7625
|
-
if (!elm) {
|
|
7679
|
+
if (!elm) {continue;}
|
|
7626
7680
|
elm.style.webkitTransition = '';
|
|
7627
7681
|
elm.style.mozTransition = '';
|
|
7628
7682
|
elm.style.transition = '';
|
|
7629
7683
|
}
|
|
7630
|
-
// clean cloned nodes and rearrange slide cells.
|
|
7631
7684
|
this$1._rearrangeNodes(newIndex);
|
|
7632
7685
|
}, NEIGHBOR_SCALE_TIME);
|
|
7633
7686
|
}, TRANSITION_TIME);
|
|
7634
7687
|
}
|
|
7635
|
-
|
|
7688
|
+
|
|
7636
7689
|
if (newIndex !== this._preIndex) {
|
|
7637
7690
|
weex.utils.dispatchNativeEvent(this.$el, 'change', {
|
|
7638
|
-
index: newIndex
|
|
7691
|
+
index: newIndex - this.cloneIndex
|
|
7639
7692
|
});
|
|
7640
7693
|
}
|
|
7694
|
+
|
|
7695
|
+
this.currentIndex = newIndex;
|
|
7696
|
+
this._preIndex = newIndex;
|
|
7641
7697
|
},
|
|
7642
|
-
|
|
7698
|
+
|
|
7643
7699
|
_clearNodesOffset: function _clearNodesOffset () {
|
|
7644
7700
|
var this$1 = this;
|
|
7645
7701
|
|
|
@@ -7734,20 +7790,20 @@ var slideMixin = {
|
|
|
7734
7790
|
node.index = idx;
|
|
7735
7791
|
node._inShow = false;
|
|
7736
7792
|
node.style.zIndex = 0;
|
|
7737
|
-
node.style.opacity = 0;
|
|
7793
|
+
// node.style.opacity = 0;
|
|
7738
7794
|
});
|
|
7739
7795
|
},
|
|
7740
7796
|
|
|
7741
7797
|
_positionNodes: function _positionNodes (begin, end, step, anim) {
|
|
7742
7798
|
var this$1 = this;
|
|
7743
|
-
|
|
7744
7799
|
var cells = this._cells;
|
|
7745
7800
|
var start = step <= 0 ? begin : end;
|
|
7746
7801
|
var stop = step <= 0 ? end : begin;
|
|
7747
7802
|
var sign = step <= 0 ? -1 : 1;
|
|
7748
7803
|
var cellIndex = this._preIndex + sign;
|
|
7749
7804
|
for (var i = start; i !== stop - sign; i = i - sign) {
|
|
7750
|
-
var
|
|
7805
|
+
var normalizedIndex = this$1._normalizeIndex(cellIndex);
|
|
7806
|
+
var node = cells[normalizedIndex].elm;
|
|
7751
7807
|
cellIndex = cellIndex - sign;
|
|
7752
7808
|
this$1._positionNode(node, i);
|
|
7753
7809
|
}
|
|
@@ -7757,26 +7813,7 @@ var slideMixin = {
|
|
|
7757
7813
|
* index: position index in the showing cells' view.
|
|
7758
7814
|
*/
|
|
7759
7815
|
_positionNode: function _positionNode (node, index) {
|
|
7760
|
-
var holder = this._showNodes[index];
|
|
7761
|
-
if (node._inShow && (holder !== node || holder._showIndex !== index)) {
|
|
7762
|
-
if (holder && holder._isClone) { this._removeClone(holder); }
|
|
7763
|
-
if( this.autoPlay ){
|
|
7764
|
-
node = this._getClone(node.index);
|
|
7765
|
-
}
|
|
7766
|
-
}
|
|
7767
|
-
else if (node._inShow) { // holder === node
|
|
7768
|
-
return
|
|
7769
|
-
}
|
|
7770
|
-
|
|
7771
7816
|
node._inShow = true;
|
|
7772
|
-
var translateX = index * this._wrapperWidth - this.innerOffset;
|
|
7773
|
-
// ddd
|
|
7774
|
-
// weex.utils.addTransform(node, {
|
|
7775
|
-
// translate: ("translate3d(" + translateX + "px, 0px, 0px)")
|
|
7776
|
-
// });
|
|
7777
|
-
// node.style.left = translateX + 'px'
|
|
7778
|
-
|
|
7779
|
-
// node.style.zIndex = 99 - Math.abs(index);
|
|
7780
7817
|
node.style.opacity = 1;
|
|
7781
7818
|
node._showIndex = index;
|
|
7782
7819
|
this._showNodes[index] = node;
|
|
@@ -7784,29 +7821,16 @@ var slideMixin = {
|
|
|
7784
7821
|
|
|
7785
7822
|
_getClone: function _getClone (index) {
|
|
7786
7823
|
var arr = this._clones[index] || (this._clones[index] = []);
|
|
7787
|
-
var origNode = this._cells[index].elm;
|
|
7824
|
+
var origNode = this._cells[index].elm;
|
|
7788
7825
|
var clone = origNode.cloneNode(true);
|
|
7789
7826
|
clone._isClone = true;
|
|
7790
7827
|
clone._inShow = true;
|
|
7791
7828
|
// clone._inShow = origNode._inShow
|
|
7792
7829
|
clone.index = origNode.index;
|
|
7793
|
-
clone.style.opacity = 0;
|
|
7794
7830
|
clone.style.zIndex = 0;
|
|
7795
7831
|
this.$refs.inner.appendChild(clone);
|
|
7796
7832
|
arr.push(clone);
|
|
7797
7833
|
return clone
|
|
7798
|
-
// try {
|
|
7799
|
-
// let arr = this._clones[index]
|
|
7800
|
-
// if (!arr) {
|
|
7801
|
-
// this._clones[index] = arr = []
|
|
7802
|
-
// }
|
|
7803
|
-
// if (arr.length <= 0) {
|
|
7804
|
-
|
|
7805
|
-
// }
|
|
7806
|
-
// return arr.pop()
|
|
7807
|
-
// } catch (err) {
|
|
7808
|
-
// console.error('this._cells -> ', this._cells)
|
|
7809
|
-
// }
|
|
7810
7834
|
},
|
|
7811
7835
|
|
|
7812
7836
|
_removeClone: function _removeClone (node) {
|
|
@@ -7822,15 +7846,10 @@ var slideMixin = {
|
|
|
7822
7846
|
// maybe cells has been updated and this clone node is already removed from the dom tree
|
|
7823
7847
|
// throught _clearClones method.
|
|
7824
7848
|
}
|
|
7825
|
-
// const idx = node.index
|
|
7826
|
-
// this._hideNode(node)
|
|
7827
|
-
// const arr = this._clones[idx]
|
|
7828
|
-
// arr.push(node)
|
|
7829
7849
|
},
|
|
7830
7850
|
|
|
7831
7851
|
_hideNode: function _hideNode (node) {
|
|
7832
7852
|
node._inShow = false;
|
|
7833
|
-
node.style.opacity = 0;
|
|
7834
7853
|
node.style.zIndex = 0;
|
|
7835
7854
|
},
|
|
7836
7855
|
|
|
@@ -7889,7 +7908,7 @@ var slideMixin = {
|
|
|
7889
7908
|
}
|
|
7890
7909
|
var origNode = origCell.elm;
|
|
7891
7910
|
if (origNode._inShow) {
|
|
7892
|
-
return
|
|
7911
|
+
return// 原始节点已在显示区域,无需替换
|
|
7893
7912
|
}
|
|
7894
7913
|
var origShowIndex = origNode._showIndex;
|
|
7895
7914
|
var styleProps = ['opacity', 'zIndex', 'left'];
|
|
@@ -7935,7 +7954,10 @@ var slideMixin = {
|
|
|
7935
7954
|
*/
|
|
7936
7955
|
var shows = this._showNodes;
|
|
7937
7956
|
for (var i = this._showStartIdx; i <= this._showEndIdx; i++) {
|
|
7938
|
-
|
|
7957
|
+
const node = this._showNodes[i];
|
|
7958
|
+
if (node) {
|
|
7959
|
+
node._inShow = false; // 重置状态
|
|
7960
|
+
}
|
|
7939
7961
|
}
|
|
7940
7962
|
for (var i$1 = -1; i$1 <= 1; i$1++) {
|
|
7941
7963
|
var node = shows[i$1];
|
|
@@ -7990,11 +8012,6 @@ var slideMixin = {
|
|
|
7990
8012
|
translateX = 0;
|
|
7991
8013
|
}
|
|
7992
8014
|
transObj.translate = "translate3d(" + translateX + "px, 0px, 0px)";
|
|
7993
|
-
|
|
7994
|
-
// ddd
|
|
7995
|
-
// weex.utils.addTransform(elm, transObj);
|
|
7996
|
-
// elm.style.left = translateX + 'px'
|
|
7997
|
-
|
|
7998
8015
|
elm.style.opacity = i === 0 ? MAIN_SLIDE_OPACITY : this$1.neighborAlpha;
|
|
7999
8016
|
}
|
|
8000
8017
|
},
|
|
@@ -8095,10 +8112,6 @@ var slideMixin = {
|
|
|
8095
8112
|
this._emitScrollEvent('weex$scroll', {
|
|
8096
8113
|
offsetXRatio: offsetX / this._wrapperWidth
|
|
8097
8114
|
});
|
|
8098
|
-
// ddd
|
|
8099
|
-
// inner.style.webkitTransform = "translate3d(" + (this.innerOffset + offsetX) + "px, 0, 0)";
|
|
8100
|
-
// inner.style.mozTransform = "translate3d(" + (this.innerOffset + offsetX) + "px, 0, 0)";
|
|
8101
|
-
// inner.style.transform = "translate3d(" + (this.innerOffset + offsetX) + "px, 0, 0)";
|
|
8102
8115
|
inner.style.left = (this .innerOffset + offsetX) + 'px'
|
|
8103
8116
|
}
|
|
8104
8117
|
},
|
|
@@ -10006,7 +10019,9 @@ function transitionOnce (vnode, config, callback) {
|
|
|
10006
10019
|
dom.removeEventListener(endEvent, transitionEndHandler);
|
|
10007
10020
|
dom.style[styleName] = '';
|
|
10008
10021
|
}
|
|
10009
|
-
|
|
10022
|
+
setTimeout(()=>{
|
|
10023
|
+
callback(); //解决嵌套animation的时候 duration过小时会出现瞬间执行完毕的问题
|
|
10024
|
+
})
|
|
10010
10025
|
};
|
|
10011
10026
|
if (endEvent) {
|
|
10012
10027
|
dom.style[styleName] = transitionValue;
|
package/package.json
CHANGED