mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 02:32:18 +00:00
[BugFix] Trigger IWidget.callback on widget drag (#514)
This commit is contained in:
@@ -2568,6 +2568,7 @@ export class LGraphCanvas implements ConnectionColorContext {
|
|||||||
pointer.onDrag = eMove => widgetInstance.onDrag({
|
pointer.onDrag = eMove => widgetInstance.onDrag({
|
||||||
e: eMove,
|
e: eMove,
|
||||||
node,
|
node,
|
||||||
|
canvas: this,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (widget.mouse) {
|
if (widget.mouse) {
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ export abstract class BaseWidget implements IBaseWidget {
|
|||||||
onDrag(options: {
|
onDrag(options: {
|
||||||
e: CanvasMouseEvent
|
e: CanvasMouseEvent
|
||||||
node: LGraphNode
|
node: LGraphNode
|
||||||
|
canvas: LGraphCanvas
|
||||||
}): void {}
|
}): void {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -146,8 +146,9 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
|
|||||||
override onDrag(options: {
|
override onDrag(options: {
|
||||||
e: CanvasMouseEvent
|
e: CanvasMouseEvent
|
||||||
node: LGraphNode
|
node: LGraphNode
|
||||||
|
canvas: LGraphCanvas
|
||||||
}) {
|
}) {
|
||||||
const { e, node } = options
|
const { e, node, canvas } = options
|
||||||
const width = this.width || node.width
|
const width = this.width || node.width
|
||||||
const x = e.canvasX - node.pos[0]
|
const x = e.canvasX - node.pos[0]
|
||||||
const delta = x < 40
|
const delta = x < 40
|
||||||
@@ -168,9 +169,7 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
|
|||||||
newValue = this.options.max
|
newValue = this.options.max
|
||||||
}
|
}
|
||||||
if (newValue !== this.value) {
|
if (newValue !== this.value) {
|
||||||
this.value = newValue
|
this.setValue(newValue, { e, node, canvas })
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ export class SliderWidget extends BaseWidget implements ISliderWidget {
|
|||||||
override onDrag(options: {
|
override onDrag(options: {
|
||||||
e: CanvasMouseEvent
|
e: CanvasMouseEvent
|
||||||
node: LGraphNode
|
node: LGraphNode
|
||||||
|
canvas: LGraphCanvas
|
||||||
}) {
|
}) {
|
||||||
if (this.options.read_only) return false
|
if (this.options.read_only) return false
|
||||||
|
|
||||||
@@ -131,9 +132,7 @@ export class SliderWidget extends BaseWidget implements ISliderWidget {
|
|||||||
const newValue = this.options.min + (this.options.max - this.options.min) * slideFactor
|
const newValue = this.options.min + (this.options.max - this.options.min) * slideFactor
|
||||||
|
|
||||||
if (newValue !== this.value) {
|
if (newValue !== this.value) {
|
||||||
this.value = newValue
|
this.setValue(newValue, options)
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user