diff --git a/src/local_view/lview_renderer.ts b/src/local_view/lview_renderer.ts index 3d4b803..7fc8bfb 100644 --- a/src/local_view/lview_renderer.ts +++ b/src/local_view/lview_renderer.ts @@ -33,8 +33,9 @@ import { ReuseDistanceOverlay } from './overlays/reuse_distance_overlay'; export class LViewRenderer { - public readonly pixiApp: Application | null = null; - public readonly viewport: Viewport | null = null; + public readonly resizeObserver: ResizeObserver; + public readonly pixiApp: Application; + public readonly viewport: Viewport; protected tooltipContainer?: JQuery; protected tooltipText?: JQuery; @@ -84,7 +85,7 @@ export class LViewRenderer { interaction: this.pixiApp.renderer.plugins.interaction, }); - const resizeObserver = new ResizeObserver(entries => { + this.resizeObserver = new ResizeObserver(entries => { entries.forEach(entry => { if (entry.contentBoxSize) { this.pixiApp?.resize(); @@ -94,7 +95,7 @@ export class LViewRenderer { } }); }); - resizeObserver.observe(this.container); + this.resizeObserver.observe(this.container); this.pixiApp.stage.addChild(this.viewport); diff --git a/src/renderer/renderer.ts b/src/renderer/renderer.ts index 6f50a1e..2b4cfe2 100644 --- a/src/renderer/renderer.ts +++ b/src/renderer/renderer.ts @@ -4101,9 +4101,10 @@ export class SDFGRenderer extends EventEmitter { if (!(this.sdfv_instance instanceof SDFV)) return; - if (this.sdfv_instance instanceof WebSDFV) { - this.container.innerHTML = ''; - this.sdfv_instance.setSDFG(this.sdfg); + const sdfv = this.sdfv_instance; + if (sdfv instanceof WebSDFV) { + sdfv.setSDFG(this.sdfg); + sdfv.getLocalViewRenderer()?.resizeObserver.disconnect(); } } @@ -4139,6 +4140,9 @@ export class SDFGRenderer extends EventEmitter { this.container.appendChild(exitBtn); this.sdfv_instance.setLocalViewRenderer(lRenderer); + + if (this.canvas) + $(this.canvas).remove(); } } catch (e) { if (e instanceof LViewGraphParseError)