pass slider type as option
This commit is contained in:
parent
d3d9ad00d8
commit
6cdc9afc7c
|
@ -250,19 +250,25 @@ function addMultilineWidget(node, name, opts, app) {
|
|||
return { minWidth: 400, minHeight: 200, widget };
|
||||
}
|
||||
|
||||
function isSlider(display_as) {
|
||||
return (display_as==="slider") ? "slider" : "number"
|
||||
}
|
||||
|
||||
export const ComfyWidgets = {
|
||||
"INT:seed": seedWidget,
|
||||
"INT:noise_seed": seedWidget,
|
||||
FLOAT(node, inputName, inputData) {
|
||||
let widgetType = isSlider(inputData[1]["display_as"]);
|
||||
const { val, config } = getNumberDefaults(inputData, 0.5);
|
||||
return { widget: node.addWidget("number", inputName, val, () => {}, config) };
|
||||
return { widget: node.addWidget(widgetType, inputName, val, () => {}, config) };
|
||||
},
|
||||
INT(node, inputName, inputData) {
|
||||
let widgetType = isSlider(inputData[1]["display_as"]);
|
||||
const { val, config } = getNumberDefaults(inputData, 1);
|
||||
Object.assign(config, { precision: 0 });
|
||||
return {
|
||||
widget: node.addWidget(
|
||||
"number",
|
||||
widgetType,
|
||||
inputName,
|
||||
val,
|
||||
function (v) {
|
||||
|
@ -270,23 +276,7 @@ export const ComfyWidgets = {
|
|||
this.value = Math.round(v / s) * s;
|
||||
},
|
||||
config
|
||||
),
|
||||
};
|
||||
},
|
||||
SLIDER(node, inputName, inputData) {
|
||||
const { val, config } = getNumberDefaults(inputData, 1);
|
||||
Object.assign(config, { precision: 0 });
|
||||
return {
|
||||
widget: node.addWidget(
|
||||
"slider",
|
||||
inputName,
|
||||
val,
|
||||
function (v) {
|
||||
const s = this.options.step / 10;
|
||||
this.value = Math.round(v / s) * s;
|
||||
},
|
||||
config
|
||||
),
|
||||
),
|
||||
};
|
||||
},
|
||||
TOGGLE(node, inputName, inputData) {
|
||||
|
|
Loading…
Reference in New Issue