Skip to content

Commit

Permalink
feat: move & up 修改为全局
Browse files Browse the repository at this point in the history
  • Loading branch information
xuying.xu committed May 19, 2023
1 parent 72e9073 commit 643f53e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
29 changes: 27 additions & 2 deletions packages/g-gesture/src/gesture.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ElementEvent } from '@antv/g-lite';

Check failure on line 1 in packages/g-gesture/src/gesture.ts

View workflow job for this annotation

GitHub Actions / lint

'ElementEvent' is defined but never used

Check failure on line 1 in packages/g-gesture/src/gesture.ts

View workflow job for this annotation

GitHub Actions / lint

'ElementEvent' is defined but never used
import type {
DisplayObject,
FederatedPointerEvent,
Expand Down Expand Up @@ -84,10 +85,34 @@ class Gesture extends EE {

private _initEvent() {
const { el } = this;
// @ts-ignore
if (el.isConnected) {
// @ts-ignore
el.ownerDocument?.defaultView.addEventListener('pointermove', this._move);
} else {
el.isMutationObserved = true;
el.on('DOMNodeInsertedIntoDocument', (e) => {
el.ownerDocument?.defaultView.addEventListener(
'pointermove',
// @ts-ignore
this._move,
);
});
}

el.addEventListener('pointerdown', this._start);
el.addEventListener('pointermove', this._move);
el.addEventListener('pointerup', this._end);

if (el.isConnected) {
// @ts-ignore
el.ownerDocument?.defaultView.addEventListener('pointerup', this._end);
} else {
el.on('DOMNodeInsertedIntoDocument', (e) => {
// @ts-ignore
el.ownerDocument?.defaultView.addEventListener('pointerup', this._end);
});
}

// el.addEventListener('pointerup', this._end);
el.addEventListener('pointercancel', this._cancel);
el.addEventListener('pointerupoutside', this._end);
}
Expand Down
3 changes: 3 additions & 0 deletions packages/g-lite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"@types/offscreencanvas": "^2019.6.1",
"@types/rbush": "^3.0.0"
},
"peerDependencies": {
"@antv/g-lite": "^1.0.0"
},
"publishConfig": {
"access": "public"
},
Expand Down

0 comments on commit 643f53e

Please sign in to comment.