Skip to content

Commit 127630a

Browse files
authored
chore: 支付宝小程使用框架自带的tap 事件 (#219)
1 parent c700298 commit 127630a

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

packages/f-my/src/index.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { Canvas } from '@antv/f-engine';
33
function convertTouches(touches) {
44
if (!touches) return touches;
55
touches.forEach((touch) => {
6-
touch.pageX = 0;
7-
touch.pageY = 0;
86
touch.clientX = touch.x;
97
touch.clientY = touch.y;
108
});
@@ -172,17 +170,16 @@ Component({
172170
onRender: onCanvasRender,
173171
// @ts-ignore
174172
offscreenCanvas: my.createOffscreenCanvas(),
175-
useNativeClickEvent: false,
173+
// useNativeClickEvent: false,
176174
isTouchEvent: (e) => e.type.startsWith('touch'),
177175
isMouseEvent: (e) => e.type.startsWith('mouse'),
178176
});
179177
this.canvas = canvas;
180178
this.canvasEl = canvas.getCanvasEl();
181179
return canvas;
182180
},
183-
click() {
184-
// 支付宝小程序的 tap 的 event 对象里没有点击的位置信息,拾取不到具体元素,所以关闭 useNativeClickEvent 用 g 里面的 click 实现
185-
// dispatchEvent(this.canvasEl, e, 'touchstart');
181+
click(e) {
182+
dispatchEvent(this.canvasEl, e, 'click');
186183
},
187184
touchStart(e) {
188185
dispatchEvent(this.canvasEl, e, 'touchstart');

packages/f-wx/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { Canvas } from '@antv/f-engine';
33
function convertTouches(touches) {
44
if (!touches) return touches;
55
touches.forEach((touch) => {
6-
touch.pageX = 0;
7-
touch.pageY = 0;
86
touch.clientX = touch.x;
97
touch.clientY = touch.y;
108
});

0 commit comments

Comments
 (0)