Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(behavior): hide elements when zooming, scrolling and dragging canvas #6054

Merged
merged 4 commits into from
Jul 17, 2024

Conversation

yvonneyx
Copy link
Contributor

  • 缩放、拖拽、滚动过程中仅显示节点 key shape
  • 主要针对 Canvas 、 SVG 渲染器下的视口(相机)操作

Jul-17-2024 14-11-10

interface OptimizeCanvasOptions extends BaseBehaviorOptions {
  /**
   * <zh/> 是否启用画布优化功能
   *
   * <en/> Whether to enable canvas optimization function
   * @defaultValue true
   */
  enable?: boolean | ((event: ViewportEvent) => boolean);
  /**
   * <zh/> 始终保留的图形类名。操作画布过程中会隐藏元素reservedShapes(除了指定类名的图形),以提高性能
   *
   * <en/> Persistently reserved shape classnames. Elements are hidden during canvas manipulation (except for shapes with specified classnames) to enhance performance.
   * @defaultValue `{ node: ['key'] }`
   */
  shapes?: {
    node?: string[];
    edge?: string[];
    combo?: string[];
  };
  /**
   * <zh/> 设置防抖时间
   *
   * <en/> Set debounce time
   * @defaultValue 200
   */
  debounce?: number;
}

packages/g6/src/behaviors/optimize-canvas.ts Outdated Show resolved Hide resolved
packages/g6/src/behaviors/optimize-canvas.ts Outdated Show resolved Hide resolved
packages/g6/src/behaviors/optimize-canvas.ts Outdated Show resolved Hide resolved
packages/g6/src/behaviors/optimize-canvas.ts Outdated Show resolved Hide resolved
packages/g6/src/behaviors/optimize-canvas.ts Outdated Show resolved Hide resolved
packages/site/.dumirc.ts Outdated Show resolved Hide resolved
@yvonneyx yvonneyx merged commit 3f775f9 into v5 Jul 17, 2024
3 checks passed
@yvonneyx yvonneyx deleted the feat/optimize-canvas branch July 17, 2024 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants