mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-06 08:00:05 +00:00
[BugFix] Fire resize callback for all dom widgets under the same node (#2882)
This commit is contained in:
@@ -6,12 +6,10 @@ import type {
|
||||
IWidgetOptions
|
||||
} from '@comfyorg/litegraph/dist/types/widgets'
|
||||
|
||||
import { useChainCallback } from '@/composables/functional/useChainCallback'
|
||||
import { app } from '@/scripts/app'
|
||||
import { useSettingStore } from '@/stores/settingStore'
|
||||
|
||||
import { app } from './app'
|
||||
|
||||
const SIZE = Symbol()
|
||||
|
||||
interface Rect {
|
||||
height: number
|
||||
width: number
|
||||
@@ -66,6 +64,13 @@ export interface DOMWidgetOptions<
|
||||
getMaxHeight?: () => number
|
||||
getHeight?: () => string | number
|
||||
onDraw?: (widget: DOMWidget<T, V>) => void
|
||||
/**
|
||||
* @deprecated Use `afterResize` instead. This callback is a legacy API
|
||||
* that fires before resize happens, but it is no longer supported. Now it
|
||||
* fires after resize happens.
|
||||
* The resize logic has been upstreamed to litegraph in
|
||||
* https://github.com/Comfy-Org/ComfyUI_frontend/pull/2557
|
||||
*/
|
||||
beforeResize?: (this: DOMWidget<T, V>, node: LGraphNode) => void
|
||||
afterResize?: (this: DOMWidget<T, V>, node: LGraphNode) => void
|
||||
}
|
||||
@@ -383,17 +388,10 @@ LGraphNode.prototype.addDOMWidget = function <
|
||||
onRemoved?.call(this)
|
||||
}
|
||||
|
||||
// @ts-ignore index with symbol
|
||||
if (!this[SIZE]) {
|
||||
// @ts-ignore index with symbol
|
||||
this[SIZE] = true
|
||||
const onResize = this.onResize
|
||||
this.onResize = function (this: LGraphNode, size: Size) {
|
||||
options.beforeResize?.call(widget, this)
|
||||
onResize?.call(this, size)
|
||||
options.afterResize?.call(widget, this)
|
||||
}
|
||||
}
|
||||
this.onResize = useChainCallback(this.onResize, () => {
|
||||
options.beforeResize?.call(widget, this)
|
||||
options.afterResize?.call(widget, this)
|
||||
})
|
||||
|
||||
return widget
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user