Remove magic 10% scale on numeric widget step (#643)

There are external code still dependent on the fact that
Widget.options.step is scaled 10x, so the 10x-ed value is still kept
there, while we use the new unscaled step2 within our code now.

Ref:
https://cs.comfy.org/search?q=context:global+%22step+/+10%22&patternType=keyword&sm=0
This commit is contained in:
Chenlei Hu
2025-02-27 16:23:53 -05:00
committed by GitHub
parent 0a09ecc7ac
commit c66ca2ae66
5 changed files with 73 additions and 9 deletions

View File

@@ -3,6 +3,8 @@ import type { LGraphNode } from "@/LGraphNode"
import type { CanvasMouseEvent } from "@/types/events"
import type { INumericWidget, IWidgetOptions } from "@/types/widgets"
import { getWidgetStep } from "@/utils/widget"
import { BaseWidget } from "./BaseWidget"
export class NumberWidget extends BaseWidget implements INumericWidget {
@@ -111,7 +113,7 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
if (delta) {
// Handle left/right arrow clicks
let newValue = this.value + delta * 0.1 * (this.options.step || 1)
let newValue = this.value + delta * getWidgetStep(this.options)
if (this.options.min != null && newValue < this.options.min) {
newValue = this.options.min
}
@@ -161,7 +163,7 @@ export class NumberWidget extends BaseWidget implements INumericWidget {
if (delta && (x > -3 && x < width + 3)) return
let newValue = this.value
if (e.deltaX) newValue += e.deltaX * 0.1 * (this.options.step || 1)
if (e.deltaX) newValue += e.deltaX * getWidgetStep(this.options)
if (this.options.min != null && newValue < this.options.min) {
newValue = this.options.min