From ffbe8f9fb9df008a2318f3843d28c6b9d7536fad Mon Sep 17 00:00:00 2001 From: James Walker Date: Thu, 14 Nov 2024 14:03:34 +0800 Subject: [PATCH] Fix slider --- src/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index bfd3121..a4c3666 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1322,7 +1322,8 @@ export class Context { ) { value = low + ((this.mousePos.x - base.x) * (high - low)) / base.w; if (step !== null && step !== 0) { - value = ((value + step / 2) / step) * step; + value = Math.round((value - low) / step) * step + low; + value = Math.max(low, Math.min(value, high)); } } // clamp and store value, update res