@dolphinweex/weex-vue-render 0.2.59 → 0.2.61

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.
@@ -1,3 +1,4 @@
1
1
  {
2
- "compile-hero.disable-compile-files-on-did-save-code": true
2
+ "compile-hero.disable-compile-files-on-did-save-code": true,
3
+ "liveServer.settings.port": 5501
3
4
  }
@@ -2919,9 +2919,16 @@ function mapFormEvents (context) {
2919
2919
  var eventMap = {};['input', 'change', 'focus', 'blur', 'return'].forEach(function (type) {
2920
2920
  eventMap[type] = function (event) {
2921
2921
  if (context.$el) {
2922
+ if(context.type === 'number' && (context.$el.value || context.$el.lastValue)){
2923
+ if(context.$el.validationMessage){//如果有报错语句 拦截使用上次数据
2924
+ context.$el.value = context.$el.lastValue
2925
+ }
2926
+ context.$el.value = context.$el.value.replace(/[^0-9eE\.\-\+]/g, '');//数字规则
2927
+ }
2922
2928
  if(context.maxlength && context.$el.value){
2923
2929
  context.$el.value = context.$el.value.slice(0,context.maxlength)
2924
2930
  }
2931
+ context.$el.lastValue = context.$el.value;
2925
2932
  event.value = context.$el.value;
2926
2933
  // for the sake of v-model, a input event must be emitted.
2927
2934
  if (type === 'input') {
@@ -2932,7 +2939,6 @@ function mapFormEvents (context) {
2932
2939
  });
2933
2940
  return eventMap
2934
2941
  }
2935
-
2936
2942
  /*
2937
2943
  * Licensed to the Apache Software Foundation (ASF) under one
2938
2944
  * or more contributor license agreements. See the NOTICE file
@@ -3479,7 +3485,7 @@ function applySrc (item, src, placeholderSrc) {
3479
3485
  return /%[0-9A-Fa-f]{2}/.test(url);
3480
3486
  }
3481
3487
 
3482
- // 优化:如果是clone节点且原始图片已加载,直接复制背景图片
3488
+ // 如果是clone节点且原始图片已加载,直接复制背景图片
3483
3489
  if (item._isClone && item._originalNode) {
3484
3490
  var originalBg = item._originalNode.style.backgroundImage;
3485
3491
  if (originalBg && originalBg !== 'none') {
@@ -5143,7 +5149,10 @@ var inputCommon = {
5143
5149
  if (autofocus) {
5144
5150
  this.$el && weex.requireModule('bridgeModule').commandInterface(JSON.stringify({ operation: 'showKeyboard'}))
5145
5151
  }
5146
- this.$el && this.$el.focus();
5152
+ //dom可能没有被获取到,延迟触发
5153
+ setTimeout(() => {
5154
+ this.$el && this.$el.focus();
5155
+ }, 200);
5147
5156
  },
5148
5157
  blur: function blur () {
5149
5158
  this.$el && this.$el.blur();
@@ -5571,7 +5580,7 @@ function getInput (weex) {
5571
5580
  if (!this._id) {
5572
5581
  this._id = idCount++;
5573
5582
  }
5574
- var events = mapFormEvents$1(this);
5583
+ var events = extend(mapFormEvents(this));
5575
5584
  return createElement('html:input', {
5576
5585
  attrs: {
5577
5586
  'weex-type': 'input',
@@ -8242,7 +8251,7 @@ var slideMixin = {
8242
8251
  this$1._clones[key] = [];
8243
8252
  });
8244
8253
 
8245
- // 优化:清理预加载的clone节点
8254
+ // 清理预加载的clone节点
8246
8255
  if (this._preloadedClones) {
8247
8256
  Object.keys(this._preloadedClones).forEach(function (key) {
8248
8257
  var clone = this$1._preloadedClones[key];
@@ -8276,7 +8285,7 @@ var slideMixin = {
8276
8285
  // node.style.opacity = 0;
8277
8286
  });
8278
8287
 
8279
- // 优化:延迟预加载clone节点,避免阻塞初始化
8288
+ // 延迟预加载clone节点,避免阻塞初始化
8280
8289
  setTimeout(function() {
8281
8290
  if (this$1.infinite && this$1.frameCount > 1) {
8282
8291
  this$1._preloadClones();
@@ -8338,7 +8347,7 @@ var slideMixin = {
8338
8347
  }
8339
8348
  },
8340
8349
 
8341
- // 优化:获取预加载的clone节点
8350
+ // 获取预加载的clone节点
8342
8351
  _getPreloadedClone: function _getPreloadedClone (index) {
8343
8352
  var key = 'preloaded_' + index;
8344
8353
  var clone = this._preloadedClones && this._preloadedClones[key];
@@ -8352,7 +8361,7 @@ var slideMixin = {
8352
8361
  return null;
8353
8362
  },
8354
8363
 
8355
- // 优化:创建优化的clone节点,预设图片
8364
+ // 创建优化的clone节点,预设图片
8356
8365
  _createOptimizedClone: function _createOptimizedClone (originalNode) {
8357
8366
  var cloneNode = originalNode.cloneNode(true);
8358
8367
  cloneNode._isClone = true;
@@ -8375,7 +8384,7 @@ var slideMixin = {
8375
8384
  return cloneNode;
8376
8385
  },
8377
8386
 
8378
- // 优化:预加载常用的clone节点
8387
+ // 预加载常用的clone节点
8379
8388
  _preloadClones: function _preloadClones () {
8380
8389
  if (!this._preloadedClones) {
8381
8390
  this._preloadedClones = {};
@@ -8599,8 +8608,12 @@ var slideMixin = {
8599
8608
  }
8600
8609
  weex.weexSliderTouchStart = true
8601
8610
 
8611
+ // 重置velocity相关变量
8602
8612
  this.lastMoveTime = Date.now();
8603
8613
  this.lastMovePosition = event.touches[0].pageX;
8614
+ this.velocity = 0;
8615
+ this.transitionDuration = 0.3;
8616
+
8604
8617
  var touch = event.changedTouches[0];
8605
8618
  this._stopAutoPlay();
8606
8619
  var inner = this.$refs.inner;
@@ -8652,18 +8665,32 @@ var slideMixin = {
8652
8665
  tp.offsetY = offsetY;
8653
8666
 
8654
8667
  const now = Date.now();
8655
- const deltaTime = now - this.lastMoveTime;
8656
- const deltaX = Math.abs(event.touches[0].pageX - this.lastMovePosition);
8657
- if (deltaTime > 0) {
8658
- this.velocity = deltaX / deltaTime; // 像素/毫秒
8659
- // 计算动画时间,速度越大动画时间越短
8660
- const baseTime = TRANSITION_TIME / 1200; // 基准时间
8661
- const minTime = 0.1; // 最小动画时间(秒)
8662
- this.transitionDuration = Math.max(minTime, baseTime / (this.velocity + 1));
8663
- }
8664
8668
 
8665
- this.lastMoveTime = now;
8666
- this.lastMovePosition = event.touches[0].pageX;
8669
+ // 初始化velocity相关变量
8670
+ if (!this.lastMoveTime) {
8671
+ this.lastMoveTime = now;
8672
+ this.lastMovePosition = event.touches[0].pageX;
8673
+ this.velocity = 0;
8674
+ this.transitionDuration = 0.3;
8675
+ } else {
8676
+ const deltaTime = now - this.lastMoveTime;
8677
+ const deltaX = Math.abs(event.touches[0].pageX - this.lastMovePosition);
8678
+
8679
+ if (deltaTime > 0 && deltaTime < 100) { // 限制deltaTime范围,避免异常值
8680
+ // 使用滑动平均来平滑velocity计算
8681
+ const currentVelocity = deltaX / deltaTime;
8682
+ this.velocity = this.velocity ? (this.velocity * 0.7 + currentVelocity * 0.3) : currentVelocity;
8683
+
8684
+ // 计算动画时间,速度越大动画时间越短
8685
+ const baseTime = TRANSITION_TIME / 1200; // 基准时间
8686
+ const minTime = 0.15; // 最小动画时间(秒)
8687
+ const maxTime = 0.5; // 最大动画时间(秒)
8688
+ this.transitionDuration = Math.max(minTime, Math.min(maxTime, baseTime / (this.velocity + 0.5)));
8689
+ }
8690
+
8691
+ this.lastMoveTime = now;
8692
+ this.lastMovePosition = event.touches[0].pageX;
8693
+ }
8667
8694
  var isV = tp.isVertical;
8668
8695
  if (typeof isV === 'undefined') {
8669
8696
  isV = tp.isVertical = Math.abs(offsetX) < Math.abs(offsetY);
@@ -8681,10 +8708,12 @@ var slideMixin = {
8681
8708
  const isRightSwipe = offsetX > 0;
8682
8709
  const atFirst = this._preIndex === 0;
8683
8710
  const atLast = this._preIndex === this.frameCount - 1;
8711
+ //修改 非无缝衔接嵌套轮播图的时候 到边界能够触发外层的轮播图滚动
8684
8712
  if (!this.infinite && !this.autoPlay && ((atLast && isLeftSwipe) || (atFirst && isRightSwipe)) && !weex.weexSliderTouchBoundary) {
8685
8713
  weex.weexSliderTouchBoundary = true
8686
- this._parentNav._touchParams = ref
8687
- //如果是边界并继续滑动
8714
+ delete this._touchParams
8715
+ this._parentNav._handleTouchStart(event)
8716
+ this._parentNav._handleTouchMove(event)
8688
8717
  return
8689
8718
  }
8690
8719
 
@@ -8724,13 +8753,13 @@ var slideMixin = {
8724
8753
 
8725
8754
  var inner = this.$refs.inner;
8726
8755
  // 如果已经有一个激活的slider,则不再处理其他slider
8727
- if (touchSliderInstance && touchSliderInstance != inner) {
8728
- event.stopPropagation();
8729
- return;
8730
- }
8756
+ // if (touchSliderInstance && touchSliderInstance != inner) {
8757
+ // event.stopPropagation();
8758
+ // return;
8759
+ // }
8731
8760
 
8732
- // horizontal scroll. trigger scroll event.
8733
- event.stopPropagation()
8761
+ // // horizontal scroll. trigger scroll event.
8762
+ // event.stopPropagation()
8734
8763
 
8735
8764
  touchSliderInstance = inner;
8736
8765
 
@@ -8780,16 +8809,205 @@ var slideMixin = {
8780
8809
  var offsetX = tp.offsetX;
8781
8810
  if (inner) {
8782
8811
  this._nodesOffsetCleared = false;
8783
- // TODO: test the velocity if it's less than 0.2.
8784
- var reset = Math.abs(offsetX / this._wrapperWidth) < 0.2;
8812
+
8813
+ // 计算滑动距离比例和方向
8814
+ var moveRatio = offsetX / this._wrapperWidth;
8815
+ var absMoveRatio = Math.abs(moveRatio);
8785
8816
  var direction = offsetX > 0 ? 1 : -1;
8786
- var newIndex = reset ? this.currentIndex : (this.currentIndex - direction);
8787
- this._slideTo(newIndex, true ,this.transitionDuration);
8817
+
8818
+ // 结合距离和速度
8819
+ var shouldSwitch = false;
8820
+ var animationDuration = this.transitionDuration || 0.3;
8821
+
8822
+ // 如果滑动距离超过30%,或者速度够快(大于0.5像素/毫秒),则切换
8823
+ if (absMoveRatio > 0.3 || (this.velocity && this.velocity > 0.5 && absMoveRatio > 0.15)) {
8824
+ shouldSwitch = true;
8825
+ // 根据速度调整动画时间,速度越快动画越短
8826
+ if (this.velocity && this.velocity > 0.3) {
8827
+ animationDuration = Math.max(0.15, Math.min(0.4, 0.4 / this.velocity));
8828
+ }
8829
+ }
8830
+
8831
+ var newIndex = shouldSwitch ? (this.currentIndex - direction) : this.currentIndex;
8832
+
8833
+ // 边界检查
8834
+ if (!this.infinite || this.infinite === 'false') {
8835
+ if (newIndex < 0) newIndex = 0;
8836
+ if (newIndex >= this.frameCount) newIndex = this.frameCount - 1;
8837
+ }
8838
+
8839
+ // 如果是复位操作(没有切换页面),使用更平滑的动画
8840
+ if (newIndex === this.currentIndex) {
8841
+ this._smoothResetPosition(inner, animationDuration);
8842
+ } else {
8843
+ this._smoothSlideTo(newIndex, animationDuration, moveRatio);
8844
+ }
8788
8845
  }
8789
8846
  delete this._touchParams;
8847
+
8848
+ // 清理velocity相关变量
8849
+ this.lastMoveTime = null;
8850
+ this.lastMovePosition = null;
8851
+ this.velocity = 0;
8852
+
8790
8853
  weex.sliderHorizontalScrolling = false;
8791
8854
  },
8792
8855
 
8856
+ // 平滑复位到当前位置
8857
+ _smoothResetPosition: function _smoothResetPosition(inner, duration) {
8858
+ var targetOffset = this.innerOffset;
8859
+ var currentOffset = this._getPosition(inner);
8860
+
8861
+ if (Math.abs(currentOffset - targetOffset) < 1) {
8862
+ return; // 位置已经很接近,无需动画
8863
+ }
8864
+
8865
+ // 使用ease-out缓动函数进行平滑复位
8866
+ var transitionStyle = this.isTransform ?
8867
+ `transform ${duration}s cubic-bezier(0.25, 0.46, 0.45, 0.94)` :
8868
+ `left ${duration}s cubic-bezier(0.25, 0.46, 0.45, 0.94)`;
8869
+
8870
+ inner.style.transition = transitionStyle;
8871
+ this._setPosition(inner, targetOffset);
8872
+
8873
+ // 清除transition
8874
+ setTimeout(() => {
8875
+ inner.style.transition = '';
8876
+ }, duration * 1000);
8877
+ },
8878
+
8879
+ // 平滑切换到目标页面
8880
+ _smoothSlideTo: function _smoothSlideTo(newIndex, duration, moveRatio) {
8881
+ var this$1 = this;
8882
+
8883
+ if (this.frameCount <= 0) return;
8884
+ if (this.frameCount <= 1) {
8885
+ this.currentIndex = 0;
8886
+ this._preIndex = 0;
8887
+ return;
8888
+ }
8889
+
8890
+ // 边界处理
8891
+ if (!this.infinite || this.infinite === 'false') {
8892
+ if (newIndex < 0 || newIndex >= this.frameCount) {
8893
+ this._smoothResetPosition(this.$refs.inner, duration);
8894
+ return;
8895
+ }
8896
+ }
8897
+
8898
+ if (this._sliding) return;
8899
+ this._sliding = true;
8900
+
8901
+ var inner = this.$refs.inner;
8902
+ if (!inner) return;
8903
+
8904
+ var originalIndex = newIndex;
8905
+ var currentOffset = this._getPosition(inner);
8906
+ var targetOffset;
8907
+ var needsReset = false;
8908
+ var cloneNode = null;
8909
+ var lastNode = null;
8910
+
8911
+ // 使用更自然的缓动函数
8912
+ var easing = Math.abs(moveRatio) > 0.4 ?
8913
+ 'cubic-bezier(0.25, 0.46, 0.45, 0.94)' : // 更快的切换
8914
+ 'cubic-bezier(0.4, 0.0, 0.2, 1)'; // 更柔和的复位
8915
+
8916
+ var transitionStyle = this.isTransform ?
8917
+ `transform ${duration}s ${easing}` :
8918
+ `left ${duration}s ${easing}`;
8919
+
8920
+ // 处理无限轮播的边界情况
8921
+ if (this.infinite && this.infinite !== 'false') {
8922
+ if (newIndex < 0) {
8923
+ // 从第一张向右滑到最后一张
8924
+ newIndex = this.frameCount - 1;
8925
+ lastNode = this._cells[newIndex].elm;
8926
+ lastNode.style.position = 'absolute';
8927
+ this._setPosition(lastNode, -this._wrapperWidth);
8928
+ lastNode.style.opacity = '1';
8929
+ lastNode.style.zIndex = '10';
8930
+
8931
+ // 目标是向右滑动到左侧的最后一张图片
8932
+ targetOffset = this.innerOffset + this._wrapperWidth;
8933
+ needsReset = true;
8934
+ } else if (newIndex >= this.frameCount) {
8935
+ // 从最后一张向左滑到第一张
8936
+ newIndex = 0;
8937
+ var firstNode = this._cells[0].elm;
8938
+ cloneNode = this._getPreloadedClone(0) || this._createOptimizedClone(firstNode);
8939
+ cloneNode.style.position = 'absolute';
8940
+ this._setPosition(cloneNode, this.frameCount * this._wrapperWidth);
8941
+ cloneNode.style.width = `${this._wrapperWidth}px`;
8942
+ cloneNode.style.zIndex = '10';
8943
+ if (!cloneNode.parentNode) {
8944
+ inner.appendChild(cloneNode);
8945
+ }
8946
+
8947
+ // 目标是向左滑动到右侧的克隆图片
8948
+ targetOffset = this.innerOffset - this._wrapperWidth;
8949
+ needsReset = true;
8950
+ } else {
8951
+ // 正常切换
8952
+ targetOffset = -newIndex * this._wrapperWidth;
8953
+ }
8954
+ } else {
8955
+ // 非无限轮播的正常切换
8956
+ targetOffset = -newIndex * this._wrapperWidth;
8957
+ }
8958
+
8959
+ // 执行动画
8960
+ inner.style.transition = transitionStyle;
8961
+ this._setPosition(inner, targetOffset);
8962
+
8963
+ // 触发滚动事件
8964
+ this._emitScrollEvent('scrollstart');
8965
+
8966
+ // 动画完成后的处理
8967
+ setTimeout(() => {
8968
+ inner.style.transition = 'none';
8969
+
8970
+ if (needsReset) {
8971
+ // 无缝轮播需要重置位置
8972
+ if (lastNode) {
8973
+ // 重置最后一张图片位置
8974
+ lastNode.style.position = '';
8975
+ lastNode.style.zIndex = '';
8976
+ this$1._setPosition(lastNode, 0);
8977
+ }
8978
+
8979
+ if (cloneNode && cloneNode.parentNode) {
8980
+ // 移除克隆节点
8981
+ inner.removeChild(cloneNode);
8982
+ }
8983
+
8984
+ // 重置到正确的最终位置
8985
+ this$1.innerOffset = -newIndex * this$1._wrapperWidth;
8986
+ this$1._setPosition(inner, this$1.innerOffset);
8987
+
8988
+ // 短暂延迟后恢复transition
8989
+ setTimeout(() => {
8990
+ inner.style.transition = '';
8991
+ }, 50);
8992
+ } else {
8993
+ this$1.innerOffset = targetOffset;
8994
+ }
8995
+
8996
+ this$1._sliding = false;
8997
+
8998
+ // 触发change事件 - 在设置currentIndex之前比较
8999
+ if (newIndex !== this$1._preIndex) {
9000
+ weex.utils.dispatchNativeEvent(this$1.$el, 'change', {
9001
+ index: newIndex
9002
+ });
9003
+ }
9004
+
9005
+ this$1.currentIndex = newIndex;
9006
+ this$1._preIndex = newIndex;
9007
+ this$1._emitScrollEvent('scrollend');
9008
+ }, duration * 1000);
9009
+ },
9010
+
8793
9011
  _handleTouchCancel: function _handleTouchCancel (event) {
8794
9012
  var inner = this.$refs.inner;
8795
9013
  if (touchSliderInstance == inner) {
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.59"
52
+ "version": "0.2.61"
53
53
  }