Skip to content

Commit

Permalink
fix: pass global runtime in svg element lifecycle contribution (#1451)
Browse files Browse the repository at this point in the history
* fix: pass global runtime in svg element lifecycle contribution

* chore: commit changeset

* fix: revert stopPropagation in g-gesture

* chore: commit changeset
  • Loading branch information
xiaoiver authored Aug 1, 2023
1 parent deaa7d8 commit 5d38414
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .changeset/kind-starfishes-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@antv/g-plugin-rough-svg-renderer': patch
'@antv/g-plugin-zdog-svg-renderer': patch
'@antv/g-gesture': patch
---

Revert stopPropagation in g-gesture
6 changes: 6 additions & 0 deletions .changeset/thirty-wasps-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@antv/g-plugin-rough-svg-renderer': patch
'@antv/g-plugin-zdog-svg-renderer': patch
---

Pass global runtime in svg element lifecycle contribution.
2 changes: 0 additions & 2 deletions packages/g-gesture/src/gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class Gesture extends EventEmitter {
} else {
el.isMutationObserved = true;
el.on(ElementEvent.MOUNTED, (e) => {
e.stopPropagation();
el.ownerDocument?.defaultView.addEventListener(
'pointermove',
// @ts-ignore
Expand All @@ -107,7 +106,6 @@ class Gesture extends EventEmitter {
el.ownerDocument?.defaultView.addEventListener('pointerup', this._end);
} else {
el.on(ElementEvent.MOUNTED, (e) => {
e.stopPropagation();
// @ts-ignore
el.ownerDocument?.defaultView.addEventListener('pointerup', this._end);
});
Expand Down
13 changes: 8 additions & 5 deletions packages/g-plugin-rough-svg-renderer/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { AbstractRendererPlugin } from '@antv/g-lite';
import { AbstractRendererPlugin, GlobalRuntime } from '@antv/g-lite';
import { RoughElementLifeCycleContribution } from './RoughElementLifeCycleContribution';
import { RoughRendererPlugin } from './RoughRendererPlugin';
export class Plugin extends AbstractRendererPlugin {
name = 'rough-svg-renderer';
init(): void {
const roughElementLifeCycleContribution = new RoughElementLifeCycleContribution(this.context);
init(runtime: GlobalRuntime): void {
const roughElementLifeCycleContribution =
new RoughElementLifeCycleContribution(this.context, runtime);

// @ts-ignore
this.context.SVGElementLifeCycleContribution = roughElementLifeCycleContribution;
this.context.SVGElementLifeCycleContribution =
roughElementLifeCycleContribution;

this.addRenderingPlugin(new RoughRendererPlugin());
}
destroy(): void {
this.removeAllRenderingPlugins();

// @ts-ignore
this.context.SVGElementLifeCycleContribution = this.context.defaultElementLifeCycleContribution;
this.context.SVGElementLifeCycleContribution =
this.context.defaultElementLifeCycleContribution;
}
}
6 changes: 3 additions & 3 deletions packages/g-plugin-zdog-svg-renderer/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AbstractRendererPlugin } from '@antv/g-lite';
import { AbstractRendererPlugin, GlobalRuntime } from '@antv/g-lite';
import { ZdogElementLifeCycleContribution } from './ZdogElementLifeCycleContribution';
import { ZdogRendererPlugin } from './ZdogRendererPlugin';
export class Plugin extends AbstractRendererPlugin {
name = 'zdog-svg-renderer';
init(): void {
init(runtime: GlobalRuntime): void {
const zdogElementLifeCycleContribution =
new ZdogElementLifeCycleContribution(this.context);
new ZdogElementLifeCycleContribution(this.context, runtime);

// @ts-ignore
this.context.SVGElementLifeCycleContribution =
Expand Down

0 comments on commit 5d38414

Please sign in to comment.