@dolphinweex/weex-harmony 0.1.98 → 0.1.100
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
|
@@ -159,6 +159,12 @@
|
|
|
159
159
|
scalePx(value , defaultVal){
|
|
160
160
|
return value ? value /this.scale : defaultVal /this.scale
|
|
161
161
|
},
|
|
162
|
+
// registerGesture.js 会对 touch.pageX/pageY 乘以 rate(=750/clientWidth)
|
|
163
|
+
// 将其转回 CSS 真实像素,与 getBoundingClientRect() 保持同一坐标系
|
|
164
|
+
toRealPx(weexPx) {
|
|
165
|
+
const rate = 750 / document.documentElement.clientWidth;
|
|
166
|
+
return weexPx / rate;
|
|
167
|
+
},
|
|
162
168
|
measureItemSize() {
|
|
163
169
|
const gridItem = this.$el.querySelector('.grid-item');
|
|
164
170
|
if (gridItem) {
|
|
@@ -290,8 +296,8 @@
|
|
|
290
296
|
}
|
|
291
297
|
this.measureItemSize();
|
|
292
298
|
const touch = e.changedTouches[0];
|
|
293
|
-
this.touchStartX = touch.pageX;
|
|
294
|
-
this.touchStartY = touch.pageY;
|
|
299
|
+
this.touchStartX = this.toRealPx(touch.pageX);
|
|
300
|
+
this.touchStartY = this.toRealPx(touch.pageY);
|
|
295
301
|
this.lastTouch = touch;
|
|
296
302
|
this.isScrolling = false;
|
|
297
303
|
|
|
@@ -303,18 +309,13 @@
|
|
|
303
309
|
}, this.longPressDuration);
|
|
304
310
|
},
|
|
305
311
|
|
|
306
|
-
//
|
|
312
|
+
// 长按回调:进入抖动编辑并立即开始拖拽(一次长按即可拖动)
|
|
307
313
|
activateDragMode(index) {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
const touch = this.lastTouch;
|
|
311
|
-
if (!touch) return;
|
|
312
|
-
this.activateDrag(index, touch);
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
// 未编辑态:进入抖动编辑(不开始拖拽)
|
|
314
|
+
const touch = this.lastTouch;
|
|
315
|
+
if (!touch) return;
|
|
316
316
|
this.isEditing = true;
|
|
317
|
-
|
|
317
|
+
console.log('[cdj-drag] activateDragMode → isEditing=true, start drag', { index });
|
|
318
|
+
this.activateDrag(index, touch);
|
|
318
319
|
},
|
|
319
320
|
|
|
320
321
|
activateDrag(index, touch) {
|
|
@@ -326,9 +327,8 @@
|
|
|
326
327
|
if (!el) return;
|
|
327
328
|
const rect = el.getBoundingClientRect();
|
|
328
329
|
|
|
329
|
-
|
|
330
|
-
this.
|
|
331
|
-
this.touchOffsetY = touch.pageY - rect.top;
|
|
330
|
+
this.touchOffsetX = this.toRealPx(touch.pageX) - rect.left;
|
|
331
|
+
this.touchOffsetY = this.toRealPx(touch.pageY) - rect.top;
|
|
332
332
|
|
|
333
333
|
// 创建拖拽克隆
|
|
334
334
|
this.createDragClone(el, rect);
|
|
@@ -372,8 +372,8 @@
|
|
|
372
372
|
if (!this.isTouchDragging && this.longPressTimer) {
|
|
373
373
|
const touch = e.changedTouches && e.changedTouches[0];
|
|
374
374
|
if (touch) {
|
|
375
|
-
const dx = Math.abs(touch.pageX - this.touchStartX);
|
|
376
|
-
const dy = Math.abs(touch.pageY - this.touchStartY);
|
|
375
|
+
const dx = Math.abs(this.toRealPx(touch.pageX) - this.touchStartX);
|
|
376
|
+
const dy = Math.abs(this.toRealPx(touch.pageY) - this.touchStartY);
|
|
377
377
|
// 垂直滚动判定优先
|
|
378
378
|
if (dy > this.scrollThreshold * 3) {
|
|
379
379
|
this.isScrolling = true;
|
|
@@ -398,9 +398,8 @@
|
|
|
398
398
|
const touch = e.changedTouches && e.changedTouches[0];
|
|
399
399
|
if (!touch) return;
|
|
400
400
|
|
|
401
|
-
|
|
402
|
-
const
|
|
403
|
-
const targetY = touch.pageY - this.touchOffsetY - this.containerRect.top;
|
|
401
|
+
const targetX = this.toRealPx(touch.pageX) - this.touchOffsetX - this.containerRect.left;
|
|
402
|
+
const targetY = this.toRealPx(touch.pageY) - this.touchOffsetY - this.containerRect.top;
|
|
404
403
|
|
|
405
404
|
// 约束在容器内部
|
|
406
405
|
const maxX = this.containerRect.width - this.itemWidth;
|
|
@@ -413,7 +412,7 @@
|
|
|
413
412
|
const now = Date.now();
|
|
414
413
|
if (now - this.lastSwapTime > 120) {
|
|
415
414
|
this.lastSwapTime = now;
|
|
416
|
-
this.maybeSwapByPosition(touch.pageX, touch.pageY);
|
|
415
|
+
this.maybeSwapByPosition(this.toRealPx(touch.pageX), this.toRealPx(touch.pageY));
|
|
417
416
|
}
|
|
418
417
|
},
|
|
419
418
|
|