@@ -10,14 +10,19 @@ import { type ComfyWidgetConstructorV2 } from '@/scripts/widgets'
1010import { useSettingStore } from '@/stores/settingStore'
1111
1212function onFloatValueChange ( this : INumericWidget , v : number ) {
13- this . value = this . options . round
14- ? _ . clamp (
15- Math . round ( ( v + Number . EPSILON ) / this . options . round ) *
16- this . options . round ,
17- this . options . min ?? - Infinity ,
18- this . options . max ?? Infinity
19- )
20- : v
13+ const round = this . options . round
14+ if ( round ) {
15+ const precision =
16+ this . options . precision ?? Math . max ( 0 , - Math . floor ( Math . log10 ( round ) ) )
17+ const rounded = Math . round ( v / round ) * round
18+ this . value = _ . clamp (
19+ Number ( rounded . toFixed ( precision ) ) ,
20+ this . options . min ?? - Infinity ,
21+ this . options . max ?? Infinity
22+ )
23+ } else {
24+ this . value = v
25+ }
2126}
2227
2328export const _for_testing = {
@@ -62,7 +67,7 @@ export const useFloatWidget = () => {
6267 max : inputSpec . max ?? 2048 ,
6368 round :
6469 enableRounding && precision && ! inputSpec . round
65- ? ( 1_000_000 * Math . pow ( 0.1 , precision ) ) / 1_000_000
70+ ? Math . pow ( 10 , - precision )
6671 : ( inputSpec . round as number ) ,
6772 /** @deprecated Use step2 instead. The 10x value is a legacy implementation. */
6873 step : step * 10.0 ,
0 commit comments