@dolphinweex/weex-harmony 0.1.34 → 0.1.36
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
@@ -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,23 +699,32 @@ 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
|
-
|
713
|
-
|
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('拖拽克隆已创建');
|
717
721
|
}
|
718
722
|
}
|
723
|
+
if(!this.data.isEditing){
|
724
|
+
setTimeout(()=>{
|
725
|
+
this.selectIconClick(null, this.data.list[index], index)
|
726
|
+
},100)
|
727
|
+
}
|
719
728
|
this.data.isEditing = true;
|
720
729
|
this.$emit('onEditStateChanged', true);
|
721
730
|
this.longPressTimer = null;
|
@@ -733,7 +742,6 @@ export default {
|
|
733
742
|
onTouchMove(e) {
|
734
743
|
if (!this.isTouchDragging) return;
|
735
744
|
|
736
|
-
// 确保在拖拽模式下阻止所有事件传播
|
737
745
|
if (this.isTouchDragging && this.data.isEditing) {
|
738
746
|
if (e.oriEvent) {
|
739
747
|
e.oriEvent.preventDefault();
|
@@ -743,17 +751,16 @@ export default {
|
|
743
751
|
}
|
744
752
|
|
745
753
|
const touch = e.changedTouches[0];
|
754
|
+
const containerRect = this.$el.getBoundingClientRect();
|
746
755
|
|
747
|
-
//
|
748
|
-
this.targetTouchX = touch.pageX;
|
749
|
-
this.targetTouchY = touch.pageY;
|
756
|
+
// 更新目标位置(相对于父容器)
|
757
|
+
this.targetTouchX = touch.pageX - containerRect.left;
|
758
|
+
this.targetTouchY = touch.pageY - containerRect.top;
|
750
759
|
|
751
|
-
// 启动平滑动画(如果尚未启动)
|
752
760
|
if (!this.animationFrameId) {
|
753
761
|
this.animationFrameId = requestAnimationFrame(this.updateDragPosition);
|
754
762
|
}
|
755
763
|
|
756
|
-
// 简化的交换逻辑
|
757
764
|
this.handleSwapLogic(touch.pageX, touch.pageY);
|
758
765
|
},
|
759
766
|
|
@@ -811,21 +818,16 @@ export default {
|
|
811
818
|
|
812
819
|
// 平滑更新拖拽位置的方法
|
813
820
|
updateDragPosition() {
|
814
|
-
const easing = 0.6;
|
815
|
-
this.
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
)
|
823
|
-
|
824
|
-
if (
|
825
|
-
Math.abs(this.dragCloneY - (this.targetTouchY - this.touchOffsetY)) <
|
826
|
-
0.5
|
827
|
-
)
|
828
|
-
this.dragCloneY = this.targetTouchY - this.touchOffsetY;
|
821
|
+
const easing = 0.6;
|
822
|
+
const targetX = this.targetTouchX - this.touchOffsetX;
|
823
|
+
const targetY = this.targetTouchY - this.touchOffsetY;
|
824
|
+
|
825
|
+
this.dragCloneX += (targetX - this.dragCloneX) * easing;
|
826
|
+
this.dragCloneY += (targetY - this.dragCloneY) * easing;
|
827
|
+
|
828
|
+
if (Math.abs(this.dragCloneX - targetX) < 0.5) this.dragCloneX = targetX;
|
829
|
+
if (Math.abs(this.dragCloneY - targetY) < 0.5) this.dragCloneY = targetY;
|
830
|
+
|
829
831
|
this.animationFrameId = requestAnimationFrame(this.updateDragPosition);
|
830
832
|
},
|
831
833
|
|
@@ -846,7 +848,11 @@ export default {
|
|
846
848
|
this.isTouchDragging = false;
|
847
849
|
this.isDragClone = false;
|
848
850
|
this.hoverIndex = null;
|
849
|
-
|
851
|
+
|
852
|
+
// 使用延时来重置拖拽索引,避免与点击事件冲突
|
853
|
+
setTimeout(() => {
|
854
|
+
this.draggingIndex = null;
|
855
|
+
}, 100);
|
850
856
|
}
|
851
857
|
},
|
852
858
|
|
@@ -1023,10 +1029,12 @@ button {
|
|
1023
1029
|
.outer-container {
|
1024
1030
|
width: 100%;
|
1025
1031
|
position: relative;
|
1032
|
+
transform-style: preserve-3d;
|
1026
1033
|
}
|
1027
1034
|
|
1028
1035
|
.items-container {
|
1029
1036
|
width: 100%;
|
1037
|
+
position: relative;
|
1030
1038
|
}
|
1031
1039
|
|
1032
1040
|
.grid-items-wrapper {
|