@dolphinweex/weex-harmony 0.1.97 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolphinweex/weex-harmony",
3
- "version": "0.1.97",
3
+ "version": "0.1.99",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -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.touchOffsetX = touch.pageX - rect.left;
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 targetX = touch.pageX - this.touchOffsetX - this.containerRect.left;
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
 
@@ -589,8 +593,8 @@
589
593
  z-index: 10000;
590
594
  }
591
595
  .modal {
592
- width: 60vw;
593
- max-width: 60vw;
596
+ width: 520px;
597
+ max-width: 520px;
594
598
  background: #fff;
595
599
  border-radius: 24px;
596
600
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);