From e009f586a2943a9ea046d2fc60cb6f84f43db594 Mon Sep 17 00:00:00 2001 From: w-e-w <40751091+w-e-w@users.noreply.github.com> Date: Wed, 20 Nov 2024 05:17:13 +0900 Subject: [PATCH] limit the minimum delta to 1 --- extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js index a788fe591..31e0b5626 100644 --- a/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js +++ b/extensions-builtin/canvas-zoom-and-pan/javascript/zoom.js @@ -483,7 +483,12 @@ onUiLoaded(async() => { const currentRadius = parseFloat(input.value); const currentArea = currentRadius ** 2; const newArea = currentArea * brush_factor; - const newValue = Math.sqrt(newArea); + let delta = Math.sqrt(newArea) - currentRadius; + // gradio seems to have a minimum brush size step of 1 + if (Math.abs(delta) < 1) { + delta = delta > 0 ? 1 : -1; + } + const newValue = currentRadius + delta; input.value = Math.min(Math.max(newValue, 0), maxValue); } input.dispatchEvent(new Event("change"));