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