mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-24 08:44:06 +00:00
fix: remove redundant forceRender call and add ResizeObserver guard (#8372)
## Summary - Remove duplicate forceRender() in ResizeObserver callback since handleResize() already calls it - Add guard for environments without ResizeObserver support - Disconnect existing observer before reassigning to prevent leaks requested by @DrJKL in https://github.com/Comfy-Org/ComfyUI_frontend/pull/8351 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8372-fix-remove-redundant-forceRender-call-and-add-ResizeObserver-guard-2f66d73d3650811bb3a6de5c59b3c1fb) by [Unito](https://www.unito.io)
This commit is contained in:
@@ -157,9 +157,11 @@ class Load3d {
|
||||
}
|
||||
|
||||
private initResizeObserver(container: Element | HTMLElement): void {
|
||||
if (typeof ResizeObserver === 'undefined') return
|
||||
|
||||
this.resizeObserver?.disconnect()
|
||||
this.resizeObserver = new ResizeObserver(() => {
|
||||
this.handleResize()
|
||||
this.forceRender()
|
||||
})
|
||||
this.resizeObserver.observe(container)
|
||||
}
|
||||
@@ -522,7 +524,6 @@ class Load3d {
|
||||
this.viewHelperManager.recreateViewHelper()
|
||||
|
||||
this.handleResize()
|
||||
this.forceRender()
|
||||
}
|
||||
|
||||
getCurrentCameraType(): 'perspective' | 'orthographic' {
|
||||
@@ -584,7 +585,6 @@ class Load3d {
|
||||
}
|
||||
|
||||
this.handleResize()
|
||||
this.forceRender()
|
||||
|
||||
this.loadingPromise = null
|
||||
}
|
||||
@@ -618,7 +618,6 @@ class Load3d {
|
||||
this.targetHeight = height
|
||||
this.targetAspectRatio = width / height
|
||||
this.handleResize()
|
||||
this.forceRender()
|
||||
}
|
||||
|
||||
addEventListener<T>(event: string, callback: EventCallback<T>): void {
|
||||
@@ -631,7 +630,6 @@ class Load3d {
|
||||
|
||||
refreshViewport(): void {
|
||||
this.handleResize()
|
||||
this.forceRender()
|
||||
}
|
||||
|
||||
handleResize(): void {
|
||||
|
||||
Reference in New Issue
Block a user