From 5721b1c27cc04873d348f9f8e20b391b8bf0c4e9 Mon Sep 17 00:00:00 2001 From: Miguel C Date: Sat, 1 Mar 2025 06:36:55 -0600 Subject: [PATCH] [Refactor] Fix step calculation in Knob Widget (#651) Removes a stray console.log and fixes the step calculation. --- src/widgets/KnobWidget.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/widgets/KnobWidget.ts b/src/widgets/KnobWidget.ts index 4b31e5cf5..b9eacd9b7 100644 --- a/src/widgets/KnobWidget.ts +++ b/src/widgets/KnobWidget.ts @@ -142,7 +142,6 @@ export class KnobWidget extends BaseWidget implements IKnobWidget { ) const gs = gradient_stops.split(";") for (const [index, stop] of gs.entries()) { - console.log(stop) gradient.addColorStop(index, stop.trim()) } @@ -212,14 +211,15 @@ export class KnobWidget extends BaseWidget implements IKnobWidget { }): void { if (this.options.read_only) return const { e } = options - const step = getWidgetStep(this.options) * 10 + const step = getWidgetStep(this.options) // Shift to move by 10% increments - const maxMinDifference = (this.options.max - this.options.min) - const maxMinDifference10pct = maxMinDifference / 10 + const range = (this.options.max - this.options.min) + const range_10_percent = range / 10 + const range_1_percent = range / 100 const step_for = { delta_x: step, - shift: maxMinDifference > step ? maxMinDifference - (maxMinDifference % step) : step, - delta_y: maxMinDifference10pct > step ? maxMinDifference10pct - (maxMinDifference10pct % step) : step, // 1% increments + shift: range_10_percent > step ? range_10_percent - (range_10_percent % step) : step, + delta_y: range_1_percent > step ? range_1_percent - (range_1_percent % step) : step, // 1% increments } const use_y = Math.abs(e.movementY) > Math.abs(e.movementX)