@dolphinweex/weex-vue-render 0.2.106 → 0.2.108
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 +151 -26
- package/package.json +1 -1
package/dist/index.common.js
CHANGED
|
@@ -10,7 +10,16 @@ console.log('START WEEX VUE RENDER: 1.0.36, Build 2018-12-29 17:52.');
|
|
|
10
10
|
|
|
11
11
|
// 记录当前已经添加过的字体
|
|
12
12
|
const AddedRules = {}
|
|
13
|
-
|
|
13
|
+
// localStorage.setItem('weexVueRenderLog',true) 开启日志
|
|
14
|
+
function __renderLog(title,log){
|
|
15
|
+
try{
|
|
16
|
+
if(localStorage && localStorage.getItem('weexVueRenderLog')){
|
|
17
|
+
console.log('[weexVueRender]' + title + ': ' + JSON.stringify(log) + ' ' + console.trace());
|
|
18
|
+
}
|
|
19
|
+
}catch(e){
|
|
20
|
+
console.error(`${JSON.stringify(e)}`)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
14
23
|
function __$styleInject(css, returnValue) {
|
|
15
24
|
if (typeof document === 'undefined') {
|
|
16
25
|
return returnValue;
|
|
@@ -2767,7 +2776,7 @@ function init$1 (viewportWidth) {
|
|
|
2767
2776
|
deviceWidth: screenWidth * dpr,
|
|
2768
2777
|
deviceHeight: screenHeight * dpr
|
|
2769
2778
|
});
|
|
2770
|
-
|
|
2779
|
+
__renderLog('[px2rem] poll@' + label + ' applied: fontSize=' + doc.documentElement.style.fontSize + ', scale=' + newScale);
|
|
2771
2780
|
}
|
|
2772
2781
|
}, delay);
|
|
2773
2782
|
};
|
|
@@ -5267,14 +5276,27 @@ var inputCommon = {
|
|
|
5267
5276
|
},
|
|
5268
5277
|
|
|
5269
5278
|
methods: {
|
|
5279
|
+
/**
|
|
5280
|
+
* 将当前输入框滚动到可视区域中间
|
|
5281
|
+
*/
|
|
5282
|
+
scrollIntoViewCenter: function scrollIntoViewCenter () {
|
|
5283
|
+
var el = this.$el;
|
|
5284
|
+
if (!el || typeof el.scrollIntoView !== 'function') { return }
|
|
5285
|
+
setTimeout(function () {
|
|
5286
|
+
el.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'smooth' });
|
|
5287
|
+
}, 50);
|
|
5288
|
+
},
|
|
5289
|
+
|
|
5270
5290
|
focus: function focus (autofocus) {
|
|
5291
|
+
var this$1 = this;
|
|
5271
5292
|
// 当是自动聚焦时才需要主动弹出键盘,否则会导致键盘弹出但是组件失去焦点
|
|
5272
5293
|
if (autofocus) {
|
|
5273
5294
|
this.$el && weex.requireModule('bridgeModule').commandInterface(JSON.stringify({ operation: 'showKeyboard'}))
|
|
5274
5295
|
}
|
|
5275
5296
|
//dom可能没有被获取到,延迟触发
|
|
5276
|
-
setTimeout(()
|
|
5277
|
-
this.$el && this.$el.focus();
|
|
5297
|
+
setTimeout(function () {
|
|
5298
|
+
this$1.$el && this$1.$el.focus();
|
|
5299
|
+
this$1.scrollIntoViewCenter();
|
|
5278
5300
|
}, 200);
|
|
5279
5301
|
},
|
|
5280
5302
|
blur: function blur () {
|
|
@@ -5312,6 +5334,13 @@ var inputCommon = {
|
|
|
5312
5334
|
|
|
5313
5335
|
// support enter key event
|
|
5314
5336
|
createKeyboardEvent: function createKeyboardEvent (events) {
|
|
5337
|
+
var this$1 = this;
|
|
5338
|
+
// 用户点击聚焦时,同样滚动到页面中间
|
|
5339
|
+
var originFocus = events.focus;
|
|
5340
|
+
events.focus = function (ev) {
|
|
5341
|
+
this$1.scrollIntoViewCenter();
|
|
5342
|
+
originFocus && originFocus.call(this, ev);
|
|
5343
|
+
};
|
|
5315
5344
|
var customKeyType = this.returnKeyType;
|
|
5316
5345
|
if (customKeyType) {
|
|
5317
5346
|
var keyboardEvents = {
|
|
@@ -8233,13 +8262,24 @@ var slideMixin = {
|
|
|
8233
8262
|
_slideTo: function _slideTo(index, isTouchScroll, transtionTime = null) {
|
|
8234
8263
|
let slideTranstionTime = this.isTransform ? `transform ${transtionTime || TRANSITION_TIME / 1600}s ease-out` : `left ${transtionTime || TRANSITION_TIME / 1600}s ease-out`
|
|
8235
8264
|
var this$1 = this;
|
|
8265
|
+
__renderLog('[weex-slider] _slideTo enter', {
|
|
8266
|
+
index: index,
|
|
8267
|
+
isTouchScroll: isTouchScroll,
|
|
8268
|
+
currentIndex: this.currentIndex,
|
|
8269
|
+
preIndex: this._preIndex,
|
|
8270
|
+
sliding: this._sliding,
|
|
8271
|
+
inited: this._inited,
|
|
8272
|
+
frameCount: this.frameCount
|
|
8273
|
+
});
|
|
8236
8274
|
if (this.frameCount <= 0) {
|
|
8275
|
+
__renderLog('[weex-slider] _slideTo return: frameCount<=0');
|
|
8237
8276
|
return;
|
|
8238
8277
|
}
|
|
8239
8278
|
//一张图片无需滚动操作
|
|
8240
8279
|
if (this.frameCount <= 1) {
|
|
8241
8280
|
this.currentIndex = 0;
|
|
8242
8281
|
this._preIndex = 0;
|
|
8282
|
+
__renderLog('[weex-slider] _slideTo return: frameCount<=1');
|
|
8243
8283
|
return;
|
|
8244
8284
|
}
|
|
8245
8285
|
// 非无限轮播的边界处理
|
|
@@ -8255,6 +8295,7 @@ var slideMixin = {
|
|
|
8255
8295
|
}
|
|
8256
8296
|
|
|
8257
8297
|
if (this._sliding) {
|
|
8298
|
+
__renderLog('[weex-slider] _slideTo return: already sliding');
|
|
8258
8299
|
return;
|
|
8259
8300
|
}
|
|
8260
8301
|
this._sliding = true;
|
|
@@ -8374,14 +8415,19 @@ var slideMixin = {
|
|
|
8374
8415
|
}, TRANSITION_TIME);
|
|
8375
8416
|
}
|
|
8376
8417
|
|
|
8377
|
-
|
|
8418
|
+
// 先同步内部 index,再派发 change,避免外部 :index 回写再次 _slideTo 闪动
|
|
8419
|
+
var prevIndex = this._preIndex;
|
|
8420
|
+
this.currentIndex = index;
|
|
8421
|
+
this._preIndex = index;
|
|
8422
|
+
__renderLog('[weex-slider] _slideTo sync index before change', {
|
|
8423
|
+
prevIndex: prevIndex,
|
|
8424
|
+
index: index
|
|
8425
|
+
});
|
|
8426
|
+
if (index !== prevIndex) {
|
|
8378
8427
|
weex.utils.dispatchNativeEvent(this.$el, 'change', {
|
|
8379
8428
|
index: index
|
|
8380
8429
|
});
|
|
8381
8430
|
}
|
|
8382
|
-
|
|
8383
|
-
this.currentIndex = index;
|
|
8384
|
-
this._preIndex = index;
|
|
8385
8431
|
},
|
|
8386
8432
|
// 优化_prepareNodes方法以支持无缝切换
|
|
8387
8433
|
_prepareNodes: function _prepareNodes() {
|
|
@@ -8794,6 +8840,11 @@ var slideMixin = {
|
|
|
8794
8840
|
this._clearNodes(2, this._showEndIdx);
|
|
8795
8841
|
this._showEndIdx = 1;
|
|
8796
8842
|
this._sliding = false;
|
|
8843
|
+
__renderLog('[weex-slider] _rearrangeNodes clear sliding', {
|
|
8844
|
+
newIndex: newIndex,
|
|
8845
|
+
currentIndex: this.currentIndex,
|
|
8846
|
+
preIndex: this._preIndex
|
|
8847
|
+
});
|
|
8797
8848
|
|
|
8798
8849
|
// set current index to the new index.
|
|
8799
8850
|
this.currentIndex = newIndex;
|
|
@@ -8861,13 +8912,34 @@ var slideMixin = {
|
|
|
8861
8912
|
}
|
|
8862
8913
|
}
|
|
8863
8914
|
if (!this.scrollable || this.frameCount<=1) {
|
|
8915
|
+
__renderLog('[weex-slider] _handleTouchStart return: not scrollable', {
|
|
8916
|
+
scrollable: this.scrollable,
|
|
8917
|
+
frameCount: this.frameCount
|
|
8918
|
+
});
|
|
8864
8919
|
return // 🚫 禁止滚动行为
|
|
8865
8920
|
}
|
|
8866
8921
|
if(weex.weexSliderTouchStart && !weex.weexSliderTouchBoundary){
|
|
8922
|
+
__renderLog('[weex-slider] _handleTouchStart return: another slider touching');
|
|
8867
8923
|
return
|
|
8868
8924
|
}
|
|
8925
|
+
// _sliding 卡住时会导致完全划不动,这里兜底释放
|
|
8926
|
+
if (this._sliding) {
|
|
8927
|
+
__renderLog('[weex-slider] _handleTouchStart force clear stuck _sliding');
|
|
8928
|
+
this._sliding = false;
|
|
8929
|
+
var stuckInner = this.$refs.inner;
|
|
8930
|
+
if (stuckInner) {
|
|
8931
|
+
stuckInner.style.transition = 'none';
|
|
8932
|
+
}
|
|
8933
|
+
}
|
|
8869
8934
|
weex.weexSliderTouchStart = true
|
|
8870
8935
|
|
|
8936
|
+
__renderLog('[weex-slider] _handleTouchStart', {
|
|
8937
|
+
currentIndex: this.currentIndex,
|
|
8938
|
+
preIndex: this._preIndex,
|
|
8939
|
+
sliding: this._sliding,
|
|
8940
|
+
frameCount: this.frameCount
|
|
8941
|
+
});
|
|
8942
|
+
|
|
8871
8943
|
// 重置velocity相关变量
|
|
8872
8944
|
this.lastMoveTime = Date.now();
|
|
8873
8945
|
this.lastMovePosition = event.touches[0].pageX;
|
|
@@ -8907,6 +8979,9 @@ var slideMixin = {
|
|
|
8907
8979
|
_handleTouchMove: function _handleTouchMove (event) {
|
|
8908
8980
|
var tp = this._touchParams;
|
|
8909
8981
|
if (!tp || !this.scrollable || this.frameCount<=1 || this._sliding) {
|
|
8982
|
+
if (this._sliding) {
|
|
8983
|
+
__renderLog('[weex-slider] _handleTouchMove blocked by _sliding');
|
|
8984
|
+
}
|
|
8910
8985
|
return // 🚫 禁止滚动行为
|
|
8911
8986
|
}
|
|
8912
8987
|
|
|
@@ -9059,13 +9134,22 @@ var slideMixin = {
|
|
|
9059
9134
|
if (touchSliderInstance == inner) {
|
|
9060
9135
|
touchSliderInstance= null;
|
|
9061
9136
|
} else {
|
|
9137
|
+
__renderLog('[weex-slider] _handleTouchEnd return: not active touchSliderInstance', {
|
|
9138
|
+
hasInner: !!inner,
|
|
9139
|
+
sliding: this._sliding,
|
|
9140
|
+
currentIndex: this.currentIndex
|
|
9141
|
+
});
|
|
9062
9142
|
return;
|
|
9063
9143
|
}
|
|
9064
9144
|
|
|
9065
9145
|
var tp = this._touchParams;
|
|
9066
|
-
if (!tp) {
|
|
9146
|
+
if (!tp) {
|
|
9147
|
+
__renderLog('[weex-slider] _handleTouchEnd return: no _touchParams');
|
|
9148
|
+
return
|
|
9149
|
+
}
|
|
9067
9150
|
var isV = tp.isVertical;
|
|
9068
9151
|
if (typeof isV === 'undefined' || isV) {
|
|
9152
|
+
__renderLog('[weex-slider] _handleTouchEnd return: vertical or unset', { isV: isV });
|
|
9069
9153
|
return
|
|
9070
9154
|
}
|
|
9071
9155
|
|
|
@@ -9099,6 +9183,16 @@ var slideMixin = {
|
|
|
9099
9183
|
if (newIndex < 0) newIndex = 0;
|
|
9100
9184
|
if (newIndex >= this.frameCount) newIndex = this.frameCount - 1;
|
|
9101
9185
|
}
|
|
9186
|
+
__renderLog('[weex-slider] _handleTouchEnd', {
|
|
9187
|
+
offsetX: offsetX,
|
|
9188
|
+
moveRatio: moveRatio,
|
|
9189
|
+
shouldSwitch: shouldSwitch,
|
|
9190
|
+
newIndex: newIndex,
|
|
9191
|
+
currentIndex: this.currentIndex,
|
|
9192
|
+
preIndex: this._preIndex,
|
|
9193
|
+
sliding: this._sliding,
|
|
9194
|
+
animationDuration: animationDuration
|
|
9195
|
+
});
|
|
9102
9196
|
|
|
9103
9197
|
// 如果是复位操作(没有切换页面),使用更平滑的动画
|
|
9104
9198
|
if (newIndex === this.currentIndex) {
|
|
@@ -9152,6 +9246,15 @@ var slideMixin = {
|
|
|
9152
9246
|
// 平滑切换到目标页面
|
|
9153
9247
|
_smoothSlideTo: function _smoothSlideTo(newIndex, duration, moveRatio) {
|
|
9154
9248
|
var this$1 = this;
|
|
9249
|
+
__renderLog('[weex-slider] _smoothSlideTo enter', {
|
|
9250
|
+
newIndex: newIndex,
|
|
9251
|
+
duration: duration,
|
|
9252
|
+
moveRatio: moveRatio,
|
|
9253
|
+
currentIndex: this.currentIndex,
|
|
9254
|
+
preIndex: this._preIndex,
|
|
9255
|
+
sliding: this._sliding,
|
|
9256
|
+
frameCount: this.frameCount
|
|
9257
|
+
});
|
|
9155
9258
|
|
|
9156
9259
|
if (this.frameCount <= 0) return;
|
|
9157
9260
|
if (this.frameCount <= 1) {
|
|
@@ -9168,7 +9271,10 @@ var slideMixin = {
|
|
|
9168
9271
|
}
|
|
9169
9272
|
}
|
|
9170
9273
|
|
|
9171
|
-
if (this._sliding)
|
|
9274
|
+
if (this._sliding) {
|
|
9275
|
+
__renderLog('[weex-slider] _smoothSlideTo return: already sliding (stuck?)');
|
|
9276
|
+
return;
|
|
9277
|
+
}
|
|
9172
9278
|
this._sliding = true;
|
|
9173
9279
|
|
|
9174
9280
|
var inner = this.$refs.inner;
|
|
@@ -9287,15 +9393,21 @@ var slideMixin = {
|
|
|
9287
9393
|
|
|
9288
9394
|
this$1._sliding = false;
|
|
9289
9395
|
|
|
9290
|
-
//
|
|
9291
|
-
|
|
9396
|
+
// 先同步内部 index,再派发 change,避免外部 :index 回写触发 watch→_slideTo 闪动
|
|
9397
|
+
var prevIndex = this$1._preIndex;
|
|
9398
|
+
this$1.currentIndex = newIndex;
|
|
9399
|
+
this$1._preIndex = newIndex;
|
|
9400
|
+
__renderLog('[weex-slider] _smoothSlideTo done, sync before change', {
|
|
9401
|
+
prevIndex: prevIndex,
|
|
9402
|
+
newIndex: newIndex,
|
|
9403
|
+
sliding: this$1._sliding
|
|
9404
|
+
});
|
|
9405
|
+
if (newIndex !== prevIndex) {
|
|
9292
9406
|
weex.utils.dispatchNativeEvent(this$1.$el, 'change', {
|
|
9293
9407
|
index: newIndex
|
|
9294
9408
|
});
|
|
9295
9409
|
}
|
|
9296
9410
|
|
|
9297
|
-
this$1.currentIndex = newIndex;
|
|
9298
|
-
this$1._preIndex = newIndex;
|
|
9299
9411
|
this$1._emitScrollEvent('scrollend');
|
|
9300
9412
|
}, duration * 1000);
|
|
9301
9413
|
},
|
|
@@ -9390,18 +9502,31 @@ var slider$1 = {
|
|
|
9390
9502
|
|
|
9391
9503
|
watch: {
|
|
9392
9504
|
index: function index () {
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9505
|
+
var normalized = this._normalizeIndex(this.index);
|
|
9506
|
+
__renderLog('[weex-slider] watch index', {
|
|
9507
|
+
propIndex: this.index,
|
|
9508
|
+
normalized: normalized,
|
|
9509
|
+
currentIndex: this.currentIndex,
|
|
9510
|
+
preIndex: this._preIndex,
|
|
9511
|
+
sliding: this._sliding
|
|
9512
|
+
});
|
|
9513
|
+
// 已与内部状态一致:手势/内部 change 回写,跳过二次 _slideTo
|
|
9514
|
+
if (normalized === Number(this.currentIndex) && normalized === Number(this._preIndex)) {
|
|
9515
|
+
__renderLog('[weex-slider] watch index skip: already at target');
|
|
9516
|
+
return;
|
|
9517
|
+
}
|
|
9518
|
+
this.currentIndex = normalized;
|
|
9519
|
+
// 如果正在滑动,强制打断并重置状态(仅外部真正切到不同页时)
|
|
9520
|
+
if (this._sliding) {
|
|
9521
|
+
__renderLog('[weex-slider] watch index interrupt sliding');
|
|
9522
|
+
var inner = this.$refs.inner;
|
|
9523
|
+
if (inner) {
|
|
9524
|
+
inner.style.transition = 'none';
|
|
9404
9525
|
}
|
|
9526
|
+
this._sliding = false;
|
|
9527
|
+
}
|
|
9528
|
+
this._slideTo(this.currentIndex);
|
|
9529
|
+
}
|
|
9405
9530
|
},
|
|
9406
9531
|
|
|
9407
9532
|
data: function data () {
|
|
@@ -11492,7 +11617,7 @@ var dom = {
|
|
|
11492
11617
|
addRule: function (key, styles) {
|
|
11493
11618
|
const rule_key = styles["fontFamily"] + styles["src"]
|
|
11494
11619
|
if (AddedRules[rule_key]) {
|
|
11495
|
-
|
|
11620
|
+
__renderLog("已经添加过字体了,无需再添加", styles.src)
|
|
11496
11621
|
return
|
|
11497
11622
|
}
|
|
11498
11623
|
|
package/package.json
CHANGED