@antv/x6 3.0.1
重大变更
- 插件整合:所有
@antv/x6-plugin-xxxx包并入主包并统一导出,原有graph.use(new Xxx())用法保持不变,仅需替换导入路径(参见src/plugin/index.ts:1-11)。 - 动画 API:移除 2.x 的
transition用法,引入全新的动画系统animate,支持命令式/配置式/自定义 Shape 动效(参见src/model/animation/animation.ts:10-21,src/model/animation/index.ts:1-8)。 - 交互默认值调整:画布平移
panning默认开启;当使用Scroller时为避免交互冲突,默认禁用画布panning(参见文档site/docs/tutorial/update.zh.md:69-71)。
功能增强
- 虚拟渲染能力:在大图场景可开启
virtual: true,仅渲染可视区域并自动加入缓冲边距以提升性能(参见src/graph/virtual-render.ts:94-106;示例见site/examples/showcase/practices/demo/virtualRender.ts:7-15)。 - 动画系统:提供
Animation、KeyframeEffect与AnimationManager,支持播放、暂停、反向、速率调整与完成/取消事件(参见src/model/animation/animation.ts:75-144,src/model/animation/animationManager.ts:3-19,src/model/animation/index.ts:1-8)。 - 插件统一导出:
Clipboard、Dnd、Export、History、Keyboard、Selection、MiniMap、Scroller、Stencil、Snapline、Transform统一从@antv/x6导出(参见src/plugin/index.ts:1-11)。
优化
- 交互体验:
panning默认开启,Selection在与panning触发冲突时具备更合理的优先级(参见site/docs/tutorial/update.zh.md:69-71)。 - 虚拟渲染性能:滚动/平移/缩放事件节流控制与渲染区域动态扩展(固定边距 120px)(参见
src/graph/virtual-render.ts:15-18,99-103)。
迁移指南
-
升级依赖:
{ "dependencies": { "@antv/x6": "^3.0.0" } } -
移除旧插件依赖:
@antv/x6-plugin-selection、@antv/x6-plugin-transform、@antv/x6-plugin-scroller、@antv/x6-plugin-keyboard、@antv/x6-plugin-history、@antv/x6-plugin-clipboard、@antv/x6-plugin-snapline、@antv/x6-plugin-dnd、@antv/x6-plugin-minimap、@antv/x6-plugin-stencil、@antv/x6-plugin-export(参见site/docs/tutorial/update.zh.md:30-43)。 -
替换导入路径:
// 2.x import { Scroller } from '@antv/x6-plugin-scroller' import { Selection } from '@antv/x6-plugin-selection' graph.use(new Scroller()) graph.use(new Selection()) // 3.x import { Scroller, Selection } from '@antv/x6' graph.use(new Scroller()) graph.use(new Selection())
-
动画迁移:将 2.x 的
transition用法迁移至 3.x 的animate能力,参考动画文档与 API(参见site/docs/tutorial/update.zh.md:61-66)。 -
配置检查:
- 若需要关闭画布平移,显式设置
panning: false。 - 使用
Scroller时可开启virtual: true以优化大图渲染。
- 若需要关闭画布平移,显式设置