@dolphinweex/weex-vue-render 0.2.105 → 0.2.107

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.
Files changed (2) hide show
  1. package/dist/index.common.js +156 -37
  2. package/package.json +1 -1
@@ -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;
@@ -2674,11 +2683,17 @@ var info = {
2674
2683
 
2675
2684
  /**
2676
2685
  * set root font-size for rem units. If already been set, just skip this.
2686
+ * 横竖屏切换时应用短边作为设计宽度:避免页面在「窗口仍横屏」时 init,把 rem 锁成 83.7(长边/10),
2687
+ * 而正常竖屏基准应为 ~38.8;横屏布局仍沿用同一套 rem/scale。
2677
2688
  */
2678
2689
  function setRootFont (width, viewportWidth, force) {
2679
2690
  var doc = window.document;
2680
- var rem = width * 750 / viewportWidth / 10;
2681
2691
  if (!doc.documentElement) { return }
2692
+ var clientW = doc.documentElement.clientWidth || width;
2693
+ var clientH = doc.documentElement.clientHeight || width;
2694
+ // 短边基准:与竖屏 init 对齐,横屏下也不要把 rem 放大到长边
2695
+ var designWidth = Math.min(clientW, clientH) || width;
2696
+ var rem = designWidth * 750 / viewportWidth / 10;
2682
2697
  var rootFontSize = doc.documentElement.style.fontSize;
2683
2698
  if (!rootFontSize || force) {
2684
2699
  doc.documentElement.style.fontSize = rem + 'px';
@@ -2728,11 +2743,15 @@ function init$1 (viewportWidth) {
2728
2743
  }
2729
2744
 
2730
2745
  dpr = info.dpr = window.devicePixelRatio;
2731
- screenWidth = doc.documentElement.clientWidth;
2732
- screenHeight = doc.documentElement.clientHeight;
2733
-
2746
+ // 用短边作为 rem/scale/deviceWidth 基准,避免横屏态下打开页面把 rem 锁成「长边/10」
2747
+ var rawW = doc.documentElement.clientWidth;
2748
+ var rawH = doc.documentElement.clientHeight;
2749
+ screenWidth = Math.min(rawW, rawH) || rawW;
2750
+ screenHeight = Math.max(rawW, rawH) || rawH;
2734
2751
  var resetDeviceHeight = function () {
2735
- screenHeight = doc.documentElement.clientHeight;
2752
+ var rw = doc.documentElement.clientWidth;
2753
+ var rh = doc.documentElement.clientHeight;
2754
+ screenHeight = Math.max(rw, rh) || rh;
2736
2755
  var env = window.weex && window.weex.config.env;
2737
2756
  info.deviceHeight = env.deviceHeight = screenHeight * dpr;
2738
2757
  };
@@ -2745,11 +2764,10 @@ function init$1 (viewportWidth) {
2745
2764
  setTimeout(function () {
2746
2765
  var newWidth = doc.documentElement.clientWidth;
2747
2766
  var newHeight = doc.documentElement.clientHeight;
2748
- console.log('[px2rem] poll@' + label + ': clientWidth=' + newWidth + ' (was ' + screenWidth + ')');
2749
- if (newWidth > screenWidth && window.orientation === 0) {
2750
- console.log('[px2rem] poll@' + label + ' FIX triggered: ' + screenWidth + ' -> ' + newWidth);
2751
- screenWidth = newWidth;
2752
- screenHeight = newHeight;
2767
+ var designW = Math.min(newWidth, newHeight) || newWidth;
2768
+ if (designW > screenWidth && Math.abs(window.orientation || 0) !== 90) {
2769
+ screenWidth = designW;
2770
+ screenHeight = Math.max(newWidth, newHeight) || newHeight;
2753
2771
  setRootFont(screenWidth, _viewportWidthForFix, true);
2754
2772
  var newScale = screenWidth / _viewportWidthForFix;
2755
2773
  document.documentElement.style.setProperty('--harmory-density-scale', newScale);
@@ -2758,7 +2776,7 @@ function init$1 (viewportWidth) {
2758
2776
  deviceWidth: screenWidth * dpr,
2759
2777
  deviceHeight: screenHeight * dpr
2760
2778
  });
2761
- console.log('[px2rem] poll@' + label + ' applied: fontSize=' + doc.documentElement.style.fontSize + ', scale=' + newScale);
2779
+ __renderLog('[px2rem] poll@' + label + ' applied: fontSize=' + doc.documentElement.style.fontSize + ', scale=' + newScale);
2762
2780
  }
2763
2781
  }, delay);
2764
2782
  };
@@ -2801,10 +2819,18 @@ function init$1 (viewportWidth) {
2801
2819
  * @return new scale.
2802
2820
  */
2803
2821
  function resetViewport (viewportWidth) {
2822
+ var doc = window.document;
2823
+ if (doc && doc.documentElement) {
2824
+ var rawW = doc.documentElement.clientWidth;
2825
+ var rawH = doc.documentElement.clientHeight;
2826
+ screenWidth = Math.min(rawW, rawH) || rawW || screenWidth;
2827
+ screenHeight = Math.max(rawW, rawH) || rawH || screenHeight;
2828
+ }
2804
2829
  setRootFont(screenWidth, viewportWidth, true);
2805
2830
  setMetaViewport(viewportWidth);
2806
2831
  var newScale = screenWidth / viewportWidth;
2807
2832
  info.scale = newScale;
2833
+ document.documentElement.style.setProperty('--harmory-density-scale', newScale);
2808
2834
  return newScale
2809
2835
  }
2810
2836
 
@@ -8216,13 +8242,24 @@ var slideMixin = {
8216
8242
  _slideTo: function _slideTo(index, isTouchScroll, transtionTime = null) {
8217
8243
  let slideTranstionTime = this.isTransform ? `transform ${transtionTime || TRANSITION_TIME / 1600}s ease-out` : `left ${transtionTime || TRANSITION_TIME / 1600}s ease-out`
8218
8244
  var this$1 = this;
8245
+ __renderLog('[weex-slider] _slideTo enter', {
8246
+ index: index,
8247
+ isTouchScroll: isTouchScroll,
8248
+ currentIndex: this.currentIndex,
8249
+ preIndex: this._preIndex,
8250
+ sliding: this._sliding,
8251
+ inited: this._inited,
8252
+ frameCount: this.frameCount
8253
+ });
8219
8254
  if (this.frameCount <= 0) {
8255
+ __renderLog('[weex-slider] _slideTo return: frameCount<=0');
8220
8256
  return;
8221
8257
  }
8222
8258
  //一张图片无需滚动操作
8223
8259
  if (this.frameCount <= 1) {
8224
8260
  this.currentIndex = 0;
8225
8261
  this._preIndex = 0;
8262
+ __renderLog('[weex-slider] _slideTo return: frameCount<=1');
8226
8263
  return;
8227
8264
  }
8228
8265
  // 非无限轮播的边界处理
@@ -8238,6 +8275,7 @@ var slideMixin = {
8238
8275
  }
8239
8276
 
8240
8277
  if (this._sliding) {
8278
+ __renderLog('[weex-slider] _slideTo return: already sliding');
8241
8279
  return;
8242
8280
  }
8243
8281
  this._sliding = true;
@@ -8357,14 +8395,19 @@ var slideMixin = {
8357
8395
  }, TRANSITION_TIME);
8358
8396
  }
8359
8397
 
8360
- if (index !== this._preIndex) {
8398
+ // 先同步内部 index,再派发 change,避免外部 :index 回写再次 _slideTo 闪动
8399
+ var prevIndex = this._preIndex;
8400
+ this.currentIndex = index;
8401
+ this._preIndex = index;
8402
+ __renderLog('[weex-slider] _slideTo sync index before change', {
8403
+ prevIndex: prevIndex,
8404
+ index: index
8405
+ });
8406
+ if (index !== prevIndex) {
8361
8407
  weex.utils.dispatchNativeEvent(this.$el, 'change', {
8362
8408
  index: index
8363
8409
  });
8364
8410
  }
8365
-
8366
- this.currentIndex = index;
8367
- this._preIndex = index;
8368
8411
  },
8369
8412
  // 优化_prepareNodes方法以支持无缝切换
8370
8413
  _prepareNodes: function _prepareNodes() {
@@ -8777,6 +8820,11 @@ var slideMixin = {
8777
8820
  this._clearNodes(2, this._showEndIdx);
8778
8821
  this._showEndIdx = 1;
8779
8822
  this._sliding = false;
8823
+ __renderLog('[weex-slider] _rearrangeNodes clear sliding', {
8824
+ newIndex: newIndex,
8825
+ currentIndex: this.currentIndex,
8826
+ preIndex: this._preIndex
8827
+ });
8780
8828
 
8781
8829
  // set current index to the new index.
8782
8830
  this.currentIndex = newIndex;
@@ -8844,13 +8892,34 @@ var slideMixin = {
8844
8892
  }
8845
8893
  }
8846
8894
  if (!this.scrollable || this.frameCount<=1) {
8895
+ __renderLog('[weex-slider] _handleTouchStart return: not scrollable', {
8896
+ scrollable: this.scrollable,
8897
+ frameCount: this.frameCount
8898
+ });
8847
8899
  return // 🚫 禁止滚动行为
8848
8900
  }
8849
8901
  if(weex.weexSliderTouchStart && !weex.weexSliderTouchBoundary){
8902
+ __renderLog('[weex-slider] _handleTouchStart return: another slider touching');
8850
8903
  return
8851
8904
  }
8905
+ // _sliding 卡住时会导致完全划不动,这里兜底释放
8906
+ if (this._sliding) {
8907
+ __renderLog('[weex-slider] _handleTouchStart force clear stuck _sliding');
8908
+ this._sliding = false;
8909
+ var stuckInner = this.$refs.inner;
8910
+ if (stuckInner) {
8911
+ stuckInner.style.transition = 'none';
8912
+ }
8913
+ }
8852
8914
  weex.weexSliderTouchStart = true
8853
8915
 
8916
+ __renderLog('[weex-slider] _handleTouchStart', {
8917
+ currentIndex: this.currentIndex,
8918
+ preIndex: this._preIndex,
8919
+ sliding: this._sliding,
8920
+ frameCount: this.frameCount
8921
+ });
8922
+
8854
8923
  // 重置velocity相关变量
8855
8924
  this.lastMoveTime = Date.now();
8856
8925
  this.lastMovePosition = event.touches[0].pageX;
@@ -8890,6 +8959,9 @@ var slideMixin = {
8890
8959
  _handleTouchMove: function _handleTouchMove (event) {
8891
8960
  var tp = this._touchParams;
8892
8961
  if (!tp || !this.scrollable || this.frameCount<=1 || this._sliding) {
8962
+ if (this._sliding) {
8963
+ __renderLog('[weex-slider] _handleTouchMove blocked by _sliding');
8964
+ }
8893
8965
  return // 🚫 禁止滚动行为
8894
8966
  }
8895
8967
 
@@ -8978,7 +9050,6 @@ var slideMixin = {
8978
9050
  // 第一张在列表开头,不能脱离文档流,否则会导致当前最后一张区域出现黑块。
8979
9051
  // 这里保留其布局位置,只做视觉位移到最右侧。
8980
9052
  var firstNode = this._cells[0].elm;
8981
- console.log('cdj-touchmove-last-to-first', { currentIndex: this.currentIndex, preIndex: this._preIndex, frameCount: this.frameCount });
8982
9053
  firstNode.style.position = this.isTransform ? '' : 'relative';
8983
9054
  this._setPosition(firstNode, this.frameCount * this._wrapperWidth);
8984
9055
  firstNode.style.opacity = '1';
@@ -9043,13 +9114,22 @@ var slideMixin = {
9043
9114
  if (touchSliderInstance == inner) {
9044
9115
  touchSliderInstance= null;
9045
9116
  } else {
9117
+ __renderLog('[weex-slider] _handleTouchEnd return: not active touchSliderInstance', {
9118
+ hasInner: !!inner,
9119
+ sliding: this._sliding,
9120
+ currentIndex: this.currentIndex
9121
+ });
9046
9122
  return;
9047
9123
  }
9048
9124
 
9049
9125
  var tp = this._touchParams;
9050
- if (!tp) { return }
9126
+ if (!tp) {
9127
+ __renderLog('[weex-slider] _handleTouchEnd return: no _touchParams');
9128
+ return
9129
+ }
9051
9130
  var isV = tp.isVertical;
9052
9131
  if (typeof isV === 'undefined' || isV) {
9132
+ __renderLog('[weex-slider] _handleTouchEnd return: vertical or unset', { isV: isV });
9053
9133
  return
9054
9134
  }
9055
9135
 
@@ -9077,13 +9157,22 @@ var slideMixin = {
9077
9157
  }
9078
9158
 
9079
9159
  var newIndex = shouldSwitch ? (this.currentIndex - direction) : this.currentIndex;
9080
- console.log('cdj-touchend-decision', { currentIndex: this.currentIndex, preIndex: this._preIndex, newIndex: newIndex, moveRatio: moveRatio, velocity: this.velocity, shouldSwitch: shouldSwitch, duration: animationDuration });
9081
9160
 
9082
9161
  // 边界检查
9083
9162
  if (!this.infinite || this.infinite === 'false') {
9084
9163
  if (newIndex < 0) newIndex = 0;
9085
9164
  if (newIndex >= this.frameCount) newIndex = this.frameCount - 1;
9086
9165
  }
9166
+ __renderLog('[weex-slider] _handleTouchEnd', {
9167
+ offsetX: offsetX,
9168
+ moveRatio: moveRatio,
9169
+ shouldSwitch: shouldSwitch,
9170
+ newIndex: newIndex,
9171
+ currentIndex: this.currentIndex,
9172
+ preIndex: this._preIndex,
9173
+ sliding: this._sliding,
9174
+ animationDuration: animationDuration
9175
+ });
9087
9176
 
9088
9177
  // 如果是复位操作(没有切换页面),使用更平滑的动画
9089
9178
  if (newIndex === this.currentIndex) {
@@ -9137,6 +9226,15 @@ var slideMixin = {
9137
9226
  // 平滑切换到目标页面
9138
9227
  _smoothSlideTo: function _smoothSlideTo(newIndex, duration, moveRatio) {
9139
9228
  var this$1 = this;
9229
+ __renderLog('[weex-slider] _smoothSlideTo enter', {
9230
+ newIndex: newIndex,
9231
+ duration: duration,
9232
+ moveRatio: moveRatio,
9233
+ currentIndex: this.currentIndex,
9234
+ preIndex: this._preIndex,
9235
+ sliding: this._sliding,
9236
+ frameCount: this.frameCount
9237
+ });
9140
9238
 
9141
9239
  if (this.frameCount <= 0) return;
9142
9240
  if (this.frameCount <= 1) {
@@ -9153,7 +9251,10 @@ var slideMixin = {
9153
9251
  }
9154
9252
  }
9155
9253
 
9156
- if (this._sliding) return;
9254
+ if (this._sliding) {
9255
+ __renderLog('[weex-slider] _smoothSlideTo return: already sliding (stuck?)');
9256
+ return;
9257
+ }
9157
9258
  this._sliding = true;
9158
9259
 
9159
9260
  var inner = this.$refs.inner;
@@ -9181,7 +9282,6 @@ var slideMixin = {
9181
9282
  if (newIndex < 0) {
9182
9283
  // 从第一张向右滑到最后一张
9183
9284
  newIndex = this.frameCount - 1;
9184
- console.log('cdj-smooth-boundary-first-to-last', { targetIndex: newIndex, innerOffset: this.innerOffset, wrapperWidth: this._wrapperWidth });
9185
9285
  lastNode = this._cells[newIndex].elm;
9186
9286
  lastNode.style.position = 'absolute';
9187
9287
  this._setPosition(lastNode, -this._wrapperWidth);
@@ -9273,15 +9373,21 @@ var slideMixin = {
9273
9373
 
9274
9374
  this$1._sliding = false;
9275
9375
 
9276
- // 触发change事件 - 在设置currentIndex之前比较
9277
- if (newIndex !== this$1._preIndex) {
9376
+ // 先同步内部 index,再派发 change,避免外部 :index 回写触发 watch→_slideTo 闪动
9377
+ var prevIndex = this$1._preIndex;
9378
+ this$1.currentIndex = newIndex;
9379
+ this$1._preIndex = newIndex;
9380
+ __renderLog('[weex-slider] _smoothSlideTo done, sync before change', {
9381
+ prevIndex: prevIndex,
9382
+ newIndex: newIndex,
9383
+ sliding: this$1._sliding
9384
+ });
9385
+ if (newIndex !== prevIndex) {
9278
9386
  weex.utils.dispatchNativeEvent(this$1.$el, 'change', {
9279
9387
  index: newIndex
9280
9388
  });
9281
9389
  }
9282
9390
 
9283
- this$1.currentIndex = newIndex;
9284
- this$1._preIndex = newIndex;
9285
9391
  this$1._emitScrollEvent('scrollend');
9286
9392
  }, duration * 1000);
9287
9393
  },
@@ -9376,18 +9482,31 @@ var slider$1 = {
9376
9482
 
9377
9483
  watch: {
9378
9484
  index: function index () {
9379
- this.currentIndex = this._normalizeIndex(this.index);
9380
- this.currentIndex = this._normalizeIndex(this.index);
9381
- // 如果正在滑动,强制打断并重置状态
9382
- if (this._sliding) {
9383
- var inner = this.$refs.inner;
9384
- if (inner) {
9385
- inner.style.transition = 'none';
9386
- }
9387
- this._sliding = false;
9388
- }
9389
- this._slideTo(this.currentIndex);
9485
+ var normalized = this._normalizeIndex(this.index);
9486
+ __renderLog('[weex-slider] watch index', {
9487
+ propIndex: this.index,
9488
+ normalized: normalized,
9489
+ currentIndex: this.currentIndex,
9490
+ preIndex: this._preIndex,
9491
+ sliding: this._sliding
9492
+ });
9493
+ // 已与内部状态一致:手势/内部 change 回写,跳过二次 _slideTo
9494
+ if (normalized === Number(this.currentIndex) && normalized === Number(this._preIndex)) {
9495
+ __renderLog('[weex-slider] watch index skip: already at target');
9496
+ return;
9497
+ }
9498
+ this.currentIndex = normalized;
9499
+ // 如果正在滑动,强制打断并重置状态(仅外部真正切到不同页时)
9500
+ if (this._sliding) {
9501
+ __renderLog('[weex-slider] watch index interrupt sliding');
9502
+ var inner = this.$refs.inner;
9503
+ if (inner) {
9504
+ inner.style.transition = 'none';
9390
9505
  }
9506
+ this._sliding = false;
9507
+ }
9508
+ this._slideTo(this.currentIndex);
9509
+ }
9391
9510
  },
9392
9511
 
9393
9512
  data: function data () {
@@ -11478,7 +11597,7 @@ var dom = {
11478
11597
  addRule: function (key, styles) {
11479
11598
  const rule_key = styles["fontFamily"] + styles["src"]
11480
11599
  if (AddedRules[rule_key]) {
11481
- console.log("已经添加过字体了,无需再添加", styles.src)
11600
+ __renderLog("已经添加过字体了,无需再添加", styles.src)
11482
11601
  return
11483
11602
  }
11484
11603
 
package/package.json CHANGED
@@ -49,5 +49,5 @@
49
49
  "type": "git",
50
50
  "url": "git+ssh://git@github.com/weexteam/weex-vue-render.git"
51
51
  },
52
- "version": "0.2.105"
52
+ "version": "0.2.107"
53
53
  }