@dolphinweex/weex-harmony 0.1.33 → 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
package/src/.DS_Store
ADDED
Binary file
|
Binary file
|
@@ -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
|
@@ -167,13 +167,11 @@ export default {
|
|
167
167
|
},
|
168
168
|
data() {
|
169
169
|
return {
|
170
|
-
isNotUpdated: true,
|
171
170
|
targetTouchX: 0,
|
172
171
|
targetTouchY: 0,
|
173
172
|
selected: null,
|
174
173
|
longPressTimer: null,
|
175
174
|
longPressDuration: 350,
|
176
|
-
longPressStartIndex: null,
|
177
175
|
draggingIndex: null,
|
178
176
|
hoverIndex: null,
|
179
177
|
isTouchDragging: false,
|
@@ -285,12 +283,6 @@ export default {
|
|
285
283
|
const animKey = `${type}-${itemId}`;
|
286
284
|
const refName = `${type}Anim-${itemId}`;
|
287
285
|
|
288
|
-
// 销毁旧动画
|
289
|
-
if (this.lottieAnimations[animKey]) {
|
290
|
-
this.lottieAnimations[animKey].destroy();
|
291
|
-
delete this.lottieAnimations[animKey];
|
292
|
-
}
|
293
|
-
|
294
286
|
// 检查DOM元素是否存在
|
295
287
|
const animEl = this.$refs[refName];
|
296
288
|
if (!animEl || !animEl[0] || !animView.animUrl) {
|
@@ -305,6 +297,36 @@ export default {
|
|
305
297
|
return;
|
306
298
|
}
|
307
299
|
|
300
|
+
// 如果是bg或front动画,需要检查并清理另一个
|
301
|
+
if (type === 'bg' || type === 'front') {
|
302
|
+
const otherType = type === 'bg' ? 'front' : 'bg';
|
303
|
+
const otherAnimKey = `${otherType}-${itemId}`;
|
304
|
+
|
305
|
+
// 如果另一个动画正在运行,先销毁它
|
306
|
+
if (this.lottieAnimations[otherAnimKey]) {
|
307
|
+
this.lottieAnimations[otherAnimKey].destroy();
|
308
|
+
delete this.lottieAnimations[otherAnimKey];
|
309
|
+
|
310
|
+
// 清空对应的animUrl数据
|
311
|
+
const index = this.data.list.findIndex(
|
312
|
+
(i) => i.itemView.id == itemId
|
313
|
+
);
|
314
|
+
if (index !== -1) {
|
315
|
+
this.$set(
|
316
|
+
this.data.list[index][`${otherType}AnimView`],
|
317
|
+
'animUrl',
|
318
|
+
''
|
319
|
+
);
|
320
|
+
}
|
321
|
+
}
|
322
|
+
}
|
323
|
+
|
324
|
+
// 销毁当前类型的旧动画
|
325
|
+
if (this.lottieAnimations[animKey]) {
|
326
|
+
this.lottieAnimations[animKey].destroy();
|
327
|
+
delete this.lottieAnimations[animKey];
|
328
|
+
}
|
329
|
+
|
308
330
|
try {
|
309
331
|
const anim = lottie.loadAnimation({
|
310
332
|
container: animEl[0],
|
@@ -374,8 +396,8 @@ export default {
|
|
374
396
|
if (item.selectIcon.visibility) {
|
375
397
|
item.itemView.isSelected = !item.itemView.isSelected;
|
376
398
|
}
|
377
|
-
e.preventDefault();
|
378
|
-
e.stopPropagation();
|
399
|
+
e && e.preventDefault();
|
400
|
+
e && e.stopPropagation();
|
379
401
|
const target = {
|
380
402
|
...item.itemView,
|
381
403
|
id: String(item.itemView.id),
|
@@ -595,7 +617,6 @@ export default {
|
|
595
617
|
return;
|
596
618
|
}
|
597
619
|
this.$emit('onDragEventStart', e);
|
598
|
-
|
599
620
|
// 只在编辑模式下阻止事件冒泡和默认行为
|
600
621
|
this.cancelLongPress();
|
601
622
|
// 记录起始触摸位置和索引
|
@@ -603,7 +624,6 @@ export default {
|
|
603
624
|
this.touchStartX = touch.pageX;
|
604
625
|
this.touchStartY = touch.pageY;
|
605
626
|
console.log('开始长按ddddddddd', touch, touch.pageY, touch.pageX);
|
606
|
-
this.longPressStartIndex = index;
|
607
627
|
this.isScrolling = false; // 重置滚动状态
|
608
628
|
|
609
629
|
// 设置新的长按计时器
|
@@ -663,7 +683,7 @@ export default {
|
|
663
683
|
activateDragMode(index) {
|
664
684
|
console.log('长按触发,进入编辑模式');
|
665
685
|
// 进入编辑模式
|
666
|
-
|
686
|
+
|
667
687
|
if (this.data.isEditing) {
|
668
688
|
// 设置当前拖拽索引
|
669
689
|
this.draggingIndex = index;
|
@@ -679,18 +699,22 @@ export default {
|
|
679
699
|
const element = document.querySelectorAll('.grid-item')[index];
|
680
700
|
if (element) {
|
681
701
|
const rect = element.getBoundingClientRect();
|
682
|
-
|
702
|
+
const containerRect = this.$el.getBoundingClientRect();
|
703
|
+
|
704
|
+
// 计算相对于父容器的偏移
|
683
705
|
this.touchOffsetX = this.touchStartX - rect.left;
|
684
706
|
this.touchOffsetY = this.touchStartY - rect.top;
|
685
707
|
|
686
|
-
//
|
687
|
-
this.dragCloneX = rect.left;
|
688
|
-
this.dragCloneY = rect.top;
|
708
|
+
// 设置克隆元素的初始位置(相对于父容器)
|
709
|
+
this.dragCloneX = rect.left - containerRect.left;
|
710
|
+
this.dragCloneY = rect.top - containerRect.top;
|
689
711
|
this.isDragClone = true;
|
690
712
|
|
691
713
|
requestAnimationFrame(() => {
|
692
|
-
|
693
|
-
|
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;
|
694
718
|
});
|
695
719
|
|
696
720
|
console.log('拖拽克隆已创建');
|
@@ -699,6 +723,9 @@ export default {
|
|
699
723
|
this.data.isEditing = true;
|
700
724
|
this.$emit('onEditStateChanged', true);
|
701
725
|
this.longPressTimer = null;
|
726
|
+
setTimeout(()=>{
|
727
|
+
this.selectIconClick(null, this.data.list[index], index)
|
728
|
+
},100)
|
702
729
|
},
|
703
730
|
|
704
731
|
// 取消长按计时器
|
@@ -707,14 +734,12 @@ export default {
|
|
707
734
|
clearTimeout(this.longPressTimer);
|
708
735
|
this.longPressTimer = null;
|
709
736
|
}
|
710
|
-
this.longPressStartIndex = null;
|
711
737
|
},
|
712
738
|
|
713
739
|
// 触摸移动处理
|
714
740
|
onTouchMove(e) {
|
715
741
|
if (!this.isTouchDragging) return;
|
716
742
|
|
717
|
-
// 确保在拖拽模式下阻止所有事件传播
|
718
743
|
if (this.isTouchDragging && this.data.isEditing) {
|
719
744
|
if (e.oriEvent) {
|
720
745
|
e.oriEvent.preventDefault();
|
@@ -724,17 +749,16 @@ export default {
|
|
724
749
|
}
|
725
750
|
|
726
751
|
const touch = e.changedTouches[0];
|
752
|
+
const containerRect = this.$el.getBoundingClientRect();
|
727
753
|
|
728
|
-
//
|
729
|
-
this.targetTouchX = touch.pageX;
|
730
|
-
this.targetTouchY = touch.pageY;
|
754
|
+
// 更新目标位置(相对于父容器)
|
755
|
+
this.targetTouchX = touch.pageX - containerRect.left;
|
756
|
+
this.targetTouchY = touch.pageY - containerRect.top;
|
731
757
|
|
732
|
-
// 启动平滑动画(如果尚未启动)
|
733
758
|
if (!this.animationFrameId) {
|
734
759
|
this.animationFrameId = requestAnimationFrame(this.updateDragPosition);
|
735
760
|
}
|
736
761
|
|
737
|
-
// 简化的交换逻辑
|
738
762
|
this.handleSwapLogic(touch.pageX, touch.pageY);
|
739
763
|
},
|
740
764
|
|
@@ -792,21 +816,16 @@ export default {
|
|
792
816
|
|
793
817
|
// 平滑更新拖拽位置的方法
|
794
818
|
updateDragPosition() {
|
795
|
-
const easing = 0.6;
|
796
|
-
this.
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
)
|
804
|
-
|
805
|
-
if (
|
806
|
-
Math.abs(this.dragCloneY - (this.targetTouchY - this.touchOffsetY)) <
|
807
|
-
0.5
|
808
|
-
)
|
809
|
-
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
|
+
|
810
829
|
this.animationFrameId = requestAnimationFrame(this.updateDragPosition);
|
811
830
|
},
|
812
831
|
|
@@ -827,7 +846,11 @@ export default {
|
|
827
846
|
this.isTouchDragging = false;
|
828
847
|
this.isDragClone = false;
|
829
848
|
this.hoverIndex = null;
|
830
|
-
|
849
|
+
|
850
|
+
// 使用延时来重置拖拽索引,避免与点击事件冲突
|
851
|
+
setTimeout(() => {
|
852
|
+
this.draggingIndex = null;
|
853
|
+
}, 100);
|
831
854
|
}
|
832
855
|
},
|
833
856
|
|
@@ -940,10 +963,10 @@ export default {
|
|
940
963
|
watch: {
|
941
964
|
'data.isEditing': {
|
942
965
|
handler(newVal) {
|
943
|
-
this.
|
944
|
-
|
945
|
-
this
|
946
|
-
}
|
966
|
+
this.generateDataList();
|
967
|
+
this.$nextTick(() => {
|
968
|
+
this.initLottieAnimations();
|
969
|
+
});
|
947
970
|
},
|
948
971
|
deep: true,
|
949
972
|
},
|
@@ -954,12 +977,13 @@ export default {
|
|
954
977
|
if (this.isProcessingData) {
|
955
978
|
return;
|
956
979
|
}
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
980
|
+
if (newList.length !== oldList.length) {
|
981
|
+
console.log('检测到data.list变化');
|
982
|
+
this.generateDataList();
|
983
|
+
this.$nextTick(() => {
|
984
|
+
this.initLottieAnimations();
|
985
|
+
});
|
986
|
+
}
|
963
987
|
},
|
964
988
|
deep: true,
|
965
989
|
},
|
@@ -974,9 +998,6 @@ export default {
|
|
974
998
|
// 初始化Lottie动画
|
975
999
|
this.initLottieAnimations();
|
976
1000
|
},
|
977
|
-
updated(){
|
978
|
-
if(this.isNotUpdated){return}
|
979
|
-
},
|
980
1001
|
beforeDestroy() {
|
981
1002
|
// 确保清理所有事件监听器
|
982
1003
|
this.cancelLongPress();
|
@@ -997,17 +1018,21 @@ export default {
|
|
997
1018
|
button {
|
998
1019
|
border: none;
|
999
1020
|
}
|
1021
|
+
|
1000
1022
|
.disabled-item {
|
1001
1023
|
opacity: 0.6;
|
1002
1024
|
pointer-events: none;
|
1003
1025
|
}
|
1026
|
+
|
1004
1027
|
.outer-container {
|
1005
1028
|
width: 100%;
|
1006
1029
|
position: relative;
|
1030
|
+
transform-style: preserve-3d;
|
1007
1031
|
}
|
1008
1032
|
|
1009
1033
|
.items-container {
|
1010
1034
|
width: 100%;
|
1035
|
+
position: relative;
|
1011
1036
|
}
|
1012
1037
|
|
1013
1038
|
.grid-items-wrapper {
|
@@ -1035,6 +1060,7 @@ button {
|
|
1035
1060
|
will-change: transform, opacity, box-shadow;
|
1036
1061
|
overflow: hidden;
|
1037
1062
|
}
|
1063
|
+
|
1038
1064
|
.grid-box {
|
1039
1065
|
position: relative;
|
1040
1066
|
display: flex;
|
@@ -1045,16 +1071,19 @@ button {
|
|
1045
1071
|
overflow: hidden;
|
1046
1072
|
height: auto;
|
1047
1073
|
}
|
1074
|
+
|
1048
1075
|
.leftTopIcon {
|
1049
1076
|
position: fixed;
|
1050
1077
|
left: 0;
|
1051
1078
|
top: 0;
|
1052
1079
|
}
|
1080
|
+
|
1053
1081
|
.actionButton {
|
1054
1082
|
display: flex;
|
1055
1083
|
justify-content: center;
|
1056
1084
|
align-items: center;
|
1057
1085
|
}
|
1086
|
+
|
1058
1087
|
/* Lottie容器样式 */
|
1059
1088
|
.lottie-container {
|
1060
1089
|
position: absolute;
|
@@ -1072,6 +1101,7 @@ button {
|
|
1072
1101
|
width: 100%;
|
1073
1102
|
height: 100%;
|
1074
1103
|
}
|
1104
|
+
|
1075
1105
|
.bg-anim,
|
1076
1106
|
.front-anim {
|
1077
1107
|
position: absolute;
|
@@ -1096,7 +1126,8 @@ button {
|
|
1096
1126
|
/* 正在拖拽的元素样式 */
|
1097
1127
|
.being-dragged {
|
1098
1128
|
z-index: 10;
|
1099
|
-
opacity: 0.3;
|
1129
|
+
opacity: 0.3;
|
1130
|
+
/* 降低原位置的不透明度 */
|
1100
1131
|
}
|
1101
1132
|
|
1102
1133
|
/* 被拖拽时原位置隐藏 */
|
@@ -1120,6 +1151,7 @@ button {
|
|
1120
1151
|
left: 0;
|
1121
1152
|
top: 0;
|
1122
1153
|
}
|
1154
|
+
|
1123
1155
|
.flexBox {
|
1124
1156
|
display: flex;
|
1125
1157
|
justify-content: space-between;
|
@@ -1127,6 +1159,7 @@ button {
|
|
1127
1159
|
position: relative;
|
1128
1160
|
flex-direction: row;
|
1129
1161
|
}
|
1162
|
+
|
1130
1163
|
.itemText {
|
1131
1164
|
display: block;
|
1132
1165
|
width: 80%;
|
@@ -1145,15 +1178,19 @@ button {
|
|
1145
1178
|
0% {
|
1146
1179
|
transform: rotateZ(2deg);
|
1147
1180
|
}
|
1181
|
+
|
1148
1182
|
25% {
|
1149
1183
|
transform: rotateZ(-2deg);
|
1150
1184
|
}
|
1185
|
+
|
1151
1186
|
50% {
|
1152
1187
|
transform: rotateZ(2deg);
|
1153
1188
|
}
|
1189
|
+
|
1154
1190
|
75% {
|
1155
1191
|
transform: rotateZ(-2deg);
|
1156
1192
|
}
|
1193
|
+
|
1157
1194
|
100% {
|
1158
1195
|
transform: rotateZ(2deg);
|
1159
1196
|
}
|