added slider and toggle widget

This commit is contained in:
Guillaume Faguet 2023-07-29 14:48:00 +02:00
parent c910b4a01c
commit d3d9ad00d8
1 changed files with 27 additions and 0 deletions

View File

@ -273,6 +273,33 @@ export const ComfyWidgets = {
),
};
},
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) {
let defaultVal = inputData[1]["default"];
return {
widget: node.addWidget(
"toggle",
inputName,
defaultVal,
() => {},
)
};
},
STRING(node, inputName, inputData, app) {
const defaultVal = inputData[1].default || "";
const multiline = !!inputData[1].multiline;