mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-30 00:00:26 +08:00
changed inc/dec to use step correctly, still issues with type
This commit is contained in:
parent
f938b3da37
commit
186c336eb7
@ -18,37 +18,29 @@ export function addValueControlWidget(node, targetWidget, defaultValue = "random
|
||||
valueControl.afterQueued = () => {
|
||||
|
||||
var v = valueControl.value;
|
||||
var w = targetWidget.type;
|
||||
|
||||
let min = targetWidget.options?.min;
|
||||
let max = targetWidget.options?.max;
|
||||
let range = Math.max(min, max);
|
||||
|
||||
//adjust values based on valueControl Behaviour
|
||||
switch (v) {
|
||||
if (min != null && max != null) {
|
||||
switch (v) {
|
||||
case "fixed":
|
||||
break;
|
||||
case "increment":
|
||||
if (min != null && max != null) {
|
||||
if (max) {
|
||||
targetWidget.value += targetWidget.options?.increment;
|
||||
}
|
||||
}
|
||||
targetWidget.value += targetWidget.options.step / 10;
|
||||
break;
|
||||
case "decrement":
|
||||
if (min != null && max != null) {
|
||||
if (max) {
|
||||
targetWidget.value -= targetWidget.options?.increment;
|
||||
}
|
||||
}
|
||||
targetWidget.value -= targetWidget.options.step / 10;
|
||||
break;
|
||||
case "randomize":
|
||||
if (min != null && max != null) {
|
||||
switch (w) {
|
||||
case "FLOAT":
|
||||
var w = targetWidget.type;
|
||||
switch (w) {
|
||||
case FLOAT:
|
||||
targetWidget.value = parseFloat((Math.floor(Math.random() * ((range * 100) + 1)) / 100).toFixed(2));
|
||||
break;
|
||||
case "INT":
|
||||
case INT:
|
||||
if (targetWidget.name == "width" || targetWidget.name == "height") {
|
||||
targetWidget.value = Math.floor(Math.random() * range) * 64 + min;
|
||||
} else {
|
||||
@ -58,11 +50,11 @@ export function addValueControlWidget(node, targetWidget, defaultValue = "random
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*check if values are over or under their respective
|
||||
* ranges and set them to min or max.*/
|
||||
if (targetWidget.value < min)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user