From 0caeaa4f2335500380d028ed492282e4b922a760 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Mon, 1 Apr 2024 18:20:16 +0800 Subject: [PATCH] feat: trigger resize event for scroller --- packages/x6-plugin-scroller/src/index.ts | 6 ++++++ packages/x6/src/graph/graph.ts | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/x6-plugin-scroller/src/index.ts b/packages/x6-plugin-scroller/src/index.ts index e452c0bcfa5..439060601fe 100644 --- a/packages/x6-plugin-scroller/src/index.ts +++ b/packages/x6-plugin-scroller/src/index.ts @@ -64,6 +64,12 @@ export class Scroller resize(width?: number, height?: number) { this.scrollerImpl.resize(width, height) + const size = { + width: this.scrollerImpl.options.width, + height: this.scrollerImpl.options.height, + } + this.trigger('resize', size) + this.graph.trigger('resize', size) } resizePage(width?: number, height?: number) { diff --git a/packages/x6/src/graph/graph.ts b/packages/x6/src/graph/graph.ts index cbb422922ba..cd40af7e0e1 100644 --- a/packages/x6/src/graph/graph.ts +++ b/packages/x6/src/graph/graph.ts @@ -556,12 +556,7 @@ export class Graph extends Basecoat { } resize(width?: number, height?: number) { - const scroller = this.getPlugin('scroller') - if (scroller) { - scroller.resize(width, height) - } else { - this.transform.resize(width, height) - } + this.size.resize(width, height) return this }