diff --git a/packages/g6/src/behaviors/zoom-canvas.ts b/packages/g6/src/behaviors/zoom-canvas.ts index 91c3ced71e0..171bbe3c5f5 100644 --- a/packages/g6/src/behaviors/zoom-canvas.ts +++ b/packages/g6/src/behaviors/zoom-canvas.ts @@ -57,6 +57,13 @@ export interface ZoomCanvasOptions extends BaseBehaviorOptions { * Callback when zooming is completed */ onFinish?: () => void; + /** + * 是否阻止默认事件 + * + * Whether to prevent the default event + * @defaultValue true + */ + preventDefault?: boolean; } /** @@ -70,6 +77,7 @@ export class ZoomCanvas extends BaseBehavior { enable: true, sensitivity: 1, trigger: [], + preventDefault: true, }; private shortcut: Shortcut; @@ -171,7 +179,7 @@ export class ZoomCanvas extends BaseBehavior { } private preventDefault = (event: Event) => { - event.preventDefault(); + if (this.options.preventDefault) event.preventDefault(); }; /**