Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
6d3dee9d
Commit
6d3dee9d
authored
Sep 18, 2023
by
comfyanonymous
Browse files
Clean up #1541.
parent
f3246393
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
web/scripts/widgets.js
web/scripts/widgets.js
+9
-8
No files found.
web/scripts/widgets.js
View file @
6d3dee9d
import
{
api
}
from
"
./api.js
"
import
{
api
}
from
"
./api.js
"
function
getNumberDefaults
(
inputData
,
defaultStep
,
app
)
{
function
getNumberDefaults
(
inputData
,
defaultStep
,
precision
,
enable_rounding
)
{
let
defaultVal
=
inputData
[
1
][
"
default
"
];
let
defaultVal
=
inputData
[
1
][
"
default
"
];
let
{
min
,
max
,
step
,
round
}
=
inputData
[
1
];
let
{
min
,
max
,
step
,
round
}
=
inputData
[
1
];
...
@@ -10,17 +10,15 @@ function getNumberDefaults(inputData, defaultStep, app) {
...
@@ -10,17 +10,15 @@ function getNumberDefaults(inputData, defaultStep, app) {
if
(
step
==
undefined
)
step
=
defaultStep
;
if
(
step
==
undefined
)
step
=
defaultStep
;
// precision is the number of decimal places to show.
// precision is the number of decimal places to show.
// by default, display the the smallest number of decimal places such that changes of size step are visible.
// by default, display the the smallest number of decimal places such that changes of size step are visible.
let
precision
=
Math
.
max
(
-
Math
.
floor
(
Math
.
log10
(
step
)),
0
);
if
(
precision
==
undefined
)
{
if
(
app
.
ui
.
settings
.
getSettingValue
(
"
Comfy.FloatRoundingPrecision
"
)
>
0
)
{
precision
=
Math
.
max
(
-
Math
.
floor
(
Math
.
log10
(
step
)),
0
);
precision
=
app
.
ui
.
settings
.
getSettingValue
(
"
Comfy.FloatRoundingPrecision
"
);
}
}
if
(
!
app
.
ui
.
settings
.
getSettingValue
(
"
Comfy.DisableFloatR
ounding
"
)
&&
(
round
==
undefined
||
round
===
true
))
{
if
(
enable_r
ounding
&&
(
round
==
undefined
||
round
===
true
))
{
// by default, round the value to those decimal places shown.
// by default, round the value to those decimal places shown.
round
=
Math
.
round
(
1000000
*
Math
.
pow
(
0.1
,
precision
))
/
1000000
;
round
=
Math
.
round
(
1000000
*
Math
.
pow
(
0.1
,
precision
))
/
1000000
;
}
}
return
{
val
:
defaultVal
,
config
:
{
min
,
max
,
step
:
10.0
*
step
,
round
,
precision
}
};
return
{
val
:
defaultVal
,
config
:
{
min
,
max
,
step
:
10.0
*
step
,
round
,
precision
}
};
}
}
...
@@ -275,7 +273,10 @@ export const ComfyWidgets = {
...
@@ -275,7 +273,10 @@ export const ComfyWidgets = {
"
INT:noise_seed
"
:
seedWidget
,
"
INT:noise_seed
"
:
seedWidget
,
FLOAT
(
node
,
inputName
,
inputData
,
app
)
{
FLOAT
(
node
,
inputName
,
inputData
,
app
)
{
let
widgetType
=
isSlider
(
inputData
[
1
][
"
display
"
],
app
);
let
widgetType
=
isSlider
(
inputData
[
1
][
"
display
"
],
app
);
const
{
val
,
config
}
=
getNumberDefaults
(
inputData
,
0.5
,
app
);
let
precision
=
app
.
ui
.
settings
.
getSettingValue
(
"
Comfy.FloatRoundingPrecision
"
);
let
disable_rounding
=
app
.
ui
.
settings
.
getSettingValue
(
"
Comfy.DisableFloatRounding
"
)
if
(
precision
==
0
)
precision
=
undefined
;
const
{
val
,
config
}
=
getNumberDefaults
(
inputData
,
0.5
,
precision
,
!
disable_rounding
);
return
{
widget
:
node
.
addWidget
(
widgetType
,
inputName
,
val
,
return
{
widget
:
node
.
addWidget
(
widgetType
,
inputName
,
val
,
function
(
v
)
{
function
(
v
)
{
if
(
config
.
round
)
{
if
(
config
.
round
)
{
...
@@ -287,7 +288,7 @@ export const ComfyWidgets = {
...
@@ -287,7 +288,7 @@ export const ComfyWidgets = {
},
},
INT
(
node
,
inputName
,
inputData
,
app
)
{
INT
(
node
,
inputName
,
inputData
,
app
)
{
let
widgetType
=
isSlider
(
inputData
[
1
][
"
display
"
],
app
);
let
widgetType
=
isSlider
(
inputData
[
1
][
"
display
"
],
app
);
const
{
val
,
config
}
=
getNumberDefaults
(
inputData
,
1
,
app
);
const
{
val
,
config
}
=
getNumberDefaults
(
inputData
,
1
,
0
,
true
);
Object
.
assign
(
config
,
{
precision
:
0
});
Object
.
assign
(
config
,
{
precision
:
0
});
return
{
return
{
widget
:
node
.
addWidget
(
widget
:
node
.
addWidget
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment