@dolphinweex/weex-harmony 0.1.98 → 0.1.99
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
|
|
|
@@ -326,9 +332,8 @@
|
|
|
326
332
|
if (!el) return;
|
|
327
333
|
const rect = el.getBoundingClientRect();
|
|
328
334
|
|
|
329
|
-
|
|
330
|
-
this.
|
|
331
|
-
this.touchOffsetY = touch.pageY - rect.top;
|
|
335
|
+
this.touchOffsetX = this.toRealPx(touch.pageX) - rect.left;
|
|
336
|
+
this.touchOffsetY = this.toRealPx(touch.pageY) - rect.top;
|
|
332
337
|
|
|
333
338
|
// 创建拖拽克隆
|
|
334
339
|
this.createDragClone(el, rect);
|
|
@@ -372,8 +377,8 @@
|
|
|
372
377
|
if (!this.isTouchDragging && this.longPressTimer) {
|
|
373
378
|
const touch = e.changedTouches && e.changedTouches[0];
|
|
374
379
|
if (touch) {
|
|
375
|
-
const dx = Math.abs(touch.pageX - this.touchStartX);
|
|
376
|
-
const dy = Math.abs(touch.pageY - this.touchStartY);
|
|
380
|
+
const dx = Math.abs(this.toRealPx(touch.pageX) - this.touchStartX);
|
|
381
|
+
const dy = Math.abs(this.toRealPx(touch.pageY) - this.touchStartY);
|
|
377
382
|
// 垂直滚动判定优先
|
|
378
383
|
if (dy > this.scrollThreshold * 3) {
|
|
379
384
|
this.isScrolling = true;
|
|
@@ -398,9 +403,8 @@
|
|
|
398
403
|
const touch = e.changedTouches && e.changedTouches[0];
|
|
399
404
|
if (!touch) return;
|
|
400
405
|
|
|
401
|
-
|
|
402
|
-
const
|
|
403
|
-
const targetY = touch.pageY - this.touchOffsetY - this.containerRect.top;
|
|
406
|
+
const targetX = this.toRealPx(touch.pageX) - this.touchOffsetX - this.containerRect.left;
|
|
407
|
+
const targetY = this.toRealPx(touch.pageY) - this.touchOffsetY - this.containerRect.top;
|
|
404
408
|
|
|
405
409
|
// 约束在容器内部
|
|
406
410
|
const maxX = this.containerRect.width - this.itemWidth;
|
|
@@ -413,7 +417,7 @@
|
|
|
413
417
|
const now = Date.now();
|
|
414
418
|
if (now - this.lastSwapTime > 120) {
|
|
415
419
|
this.lastSwapTime = now;
|
|
416
|
-
this.maybeSwapByPosition(touch.pageX, touch.pageY);
|
|
420
|
+
this.maybeSwapByPosition(this.toRealPx(touch.pageX), this.toRealPx(touch.pageY));
|
|
417
421
|
}
|
|
418
422
|
},
|
|
419
423
|
|