Skip to content

Commit

Permalink
Release (#1518)
Browse files Browse the repository at this point in the history
* fix: 修复touchend事件不触发导致手势事件异常 (#1516)

* fix: 部分机器不触发touchend事件

* chore: 更新changes

* fix: 对齐touches问题

---------

Co-authored-by: 兵人 <[email protected]>

* chore(release): bump version (#1517)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: BING <[email protected]>
Co-authored-by: 兵人 <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Sep 4, 2023
1 parent aa27b8b commit 189708e
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
7 changes: 7 additions & 0 deletions packages/g-mobile-canvas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-mobile-canvas

## 0.11.4

### Patch Changes

- Updated dependencies [a2f2de20]
- @antv/g-plugin-gesture@1.2.1

## 0.11.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-mobile-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-mobile-canvas",
"version": "0.11.3",
"version": "0.11.4",
"description": "A renderer implemented with Canvas2D API in mobile environment",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-plugin-gesture/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-plugin-gesture

## 1.2.1

### Patch Changes

- a2f2de20: 修复 touchend 事件不触发导致手势事件异常

## 1.2.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-gesture/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-gesture",
"version": "1.2.0",
"version": "1.2.1",
"description": "A G plugin for Gesture implemented with PointerEvents",
"keywords": [
"antv",
Expand Down
29 changes: 28 additions & 1 deletion packages/g-plugin-gesture/src/GesturePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class GesturePlugin implements RenderingPlugin {
private lastMovePoint: Point;
private throttleTimer = 0;
private emitThrottles: EmitEventObject[] = [];
private movingTarget: DisplayObject;
private movingTarget: IEventTarget;
private isPanListenerInPath: boolean;

constructor(private options: GesturePluginOptions) {}
Expand Down Expand Up @@ -109,12 +109,37 @@ export class GesturePlugin implements RenderingPlugin {
const { evCache, startPoints } = this;
if (ev) {
const { pointerId, x, y } = ev;

// evcache 已经存在的 pointerId, 做替换
const existIdx = evCache.findIndex((item) => pointerId === item.pointerId);
if (existIdx !== -1){
evCache.splice(existIdx, 1);
}

// evCache 不存在的 pointerId, 添加
evCache.push({
pointerId,
x,
y,
ev,
});

// @ts-ignore 对齐touches evCache 存在,touches 不存在,移除
const evTouches = [...(ev.nativeEvent?.touches || [])];
for (let i = evCache.length - 1; i > -1; i--) {

const isInTouches = evTouches.find(touch => {
return evCache[i].pointerId === touch.identifier
})

// 在touches中存在
if (isInTouches) {
continue
}

// 在touches中不存在
evCache.splice(i, 1);
}
}
// 重置 startPoints
startPoints.length = evCache.length;
Expand Down Expand Up @@ -144,6 +169,7 @@ export class GesturePlugin implements RenderingPlugin {

this.eventType = eventType;
this.direction = direction;

this.movingTarget = target;
}, PRESS_DELAY);
return;
Expand Down Expand Up @@ -395,6 +421,7 @@ export class GesturePlugin implements RenderingPlugin {

private refreshAndGetTarget(target) {
if (this.movingTarget) {
// @ts-ignore
if (this.movingTarget && !this.movingTarget.isConnected) {
this.movingTarget = target;
}
Expand Down

0 comments on commit 189708e

Please sign in to comment.