@dolphinweex/weex-harmony 0.1.34 → 0.1.35

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolphinweex/weex-harmony",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -48,7 +48,7 @@
48
48
  :style="applyNormalAttribute(item.itemView)"
49
49
  class="grid-box"
50
50
  :class="{ shaking: data.isEditing }"
51
- @click.stop="(e) => itemViewClick(e, item, index)"
51
+ @click.stop.prevent="(e) => itemViewClick(e, item, index)"
52
52
  >
53
53
  <div class="flexBox">
54
54
  <img
@@ -396,8 +396,8 @@ export default {
396
396
  if (item.selectIcon.visibility) {
397
397
  item.itemView.isSelected = !item.itemView.isSelected;
398
398
  }
399
- e.preventDefault();
400
- e.stopPropagation();
399
+ e && e.preventDefault();
400
+ e && e.stopPropagation();
401
401
  const target = {
402
402
  ...item.itemView,
403
403
  id: String(item.itemView.id),
@@ -683,7 +683,7 @@ export default {
683
683
  activateDragMode(index) {
684
684
  console.log('长按触发,进入编辑模式');
685
685
  // 进入编辑模式
686
-
686
+
687
687
  if (this.data.isEditing) {
688
688
  // 设置当前拖拽索引
689
689
  this.draggingIndex = index;
@@ -699,18 +699,22 @@ export default {
699
699
  const element = document.querySelectorAll('.grid-item')[index];
700
700
  if (element) {
701
701
  const rect = element.getBoundingClientRect();
702
- // 计算触摸点相对于元素左上角的偏移
702
+ const containerRect = this.$el.getBoundingClientRect();
703
+
704
+ // 计算相对于父容器的偏移
703
705
  this.touchOffsetX = this.touchStartX - rect.left;
704
706
  this.touchOffsetY = this.touchStartY - rect.top;
705
707
 
706
- // 设置克隆元素的初始位置
707
- this.dragCloneX = rect.left;
708
- this.dragCloneY = rect.top;
708
+ // 设置克隆元素的初始位置(相对于父容器)
709
+ this.dragCloneX = rect.left - containerRect.left;
710
+ this.dragCloneY = rect.top - containerRect.top;
709
711
  this.isDragClone = true;
710
712
 
711
713
  requestAnimationFrame(() => {
712
- this.dragCloneX = this.touchStartX - this.touchOffsetX;
713
- this.dragCloneY = this.touchStartY - this.touchOffsetY;
714
+ const relativeX = this.touchStartX - containerRect.left - this.touchOffsetX;
715
+ const relativeY = this.touchStartY - containerRect.top - this.touchOffsetY;
716
+ this.dragCloneX = relativeX;
717
+ this.dragCloneY = relativeY;
714
718
  });
715
719
 
716
720
  console.log('拖拽克隆已创建');
@@ -719,6 +723,9 @@ export default {
719
723
  this.data.isEditing = true;
720
724
  this.$emit('onEditStateChanged', true);
721
725
  this.longPressTimer = null;
726
+ setTimeout(()=>{
727
+ this.selectIconClick(null, this.data.list[index], index)
728
+ },100)
722
729
  },
723
730
 
724
731
  // 取消长按计时器
@@ -733,7 +740,6 @@ export default {
733
740
  onTouchMove(e) {
734
741
  if (!this.isTouchDragging) return;
735
742
 
736
- // 确保在拖拽模式下阻止所有事件传播
737
743
  if (this.isTouchDragging && this.data.isEditing) {
738
744
  if (e.oriEvent) {
739
745
  e.oriEvent.preventDefault();
@@ -743,17 +749,16 @@ export default {
743
749
  }
744
750
 
745
751
  const touch = e.changedTouches[0];
752
+ const containerRect = this.$el.getBoundingClientRect();
746
753
 
747
- // 更新目标位置而非直接设置
748
- this.targetTouchX = touch.pageX;
749
- this.targetTouchY = touch.pageY;
754
+ // 更新目标位置(相对于父容器)
755
+ this.targetTouchX = touch.pageX - containerRect.left;
756
+ this.targetTouchY = touch.pageY - containerRect.top;
750
757
 
751
- // 启动平滑动画(如果尚未启动)
752
758
  if (!this.animationFrameId) {
753
759
  this.animationFrameId = requestAnimationFrame(this.updateDragPosition);
754
760
  }
755
761
 
756
- // 简化的交换逻辑
757
762
  this.handleSwapLogic(touch.pageX, touch.pageY);
758
763
  },
759
764
 
@@ -811,21 +816,16 @@ export default {
811
816
 
812
817
  // 平滑更新拖拽位置的方法
813
818
  updateDragPosition() {
814
- const easing = 0.6; // 增加缓动系数,让拖拽更跟手
815
- this.dragCloneX +=
816
- (this.targetTouchX - this.touchOffsetX - this.dragCloneX) * easing;
817
- this.dragCloneY +=
818
- (this.targetTouchY - this.touchOffsetY - this.dragCloneY) * easing;
819
- if (
820
- Math.abs(this.dragCloneX - (this.targetTouchX - this.touchOffsetX)) <
821
- 0.5
822
- )
823
- this.dragCloneX = this.targetTouchX - this.touchOffsetX;
824
- if (
825
- Math.abs(this.dragCloneY - (this.targetTouchY - this.touchOffsetY)) <
826
- 0.5
827
- )
828
- this.dragCloneY = this.targetTouchY - this.touchOffsetY;
819
+ const easing = 0.6;
820
+ const targetX = this.targetTouchX - this.touchOffsetX;
821
+ const targetY = this.targetTouchY - this.touchOffsetY;
822
+
823
+ this.dragCloneX += (targetX - this.dragCloneX) * easing;
824
+ this.dragCloneY += (targetY - this.dragCloneY) * easing;
825
+
826
+ if (Math.abs(this.dragCloneX - targetX) < 0.5) this.dragCloneX = targetX;
827
+ if (Math.abs(this.dragCloneY - targetY) < 0.5) this.dragCloneY = targetY;
828
+
829
829
  this.animationFrameId = requestAnimationFrame(this.updateDragPosition);
830
830
  },
831
831
 
@@ -846,7 +846,11 @@ export default {
846
846
  this.isTouchDragging = false;
847
847
  this.isDragClone = false;
848
848
  this.hoverIndex = null;
849
- this.draggingIndex = null;
849
+
850
+ // 使用延时来重置拖拽索引,避免与点击事件冲突
851
+ setTimeout(() => {
852
+ this.draggingIndex = null;
853
+ }, 100);
850
854
  }
851
855
  },
852
856
 
@@ -1023,10 +1027,12 @@ button {
1023
1027
  .outer-container {
1024
1028
  width: 100%;
1025
1029
  position: relative;
1030
+ transform-style: preserve-3d;
1026
1031
  }
1027
1032
 
1028
1033
  .items-container {
1029
1034
  width: 100%;
1035
+ position: relative;
1030
1036
  }
1031
1037
 
1032
1038
  .grid-items-wrapper {