From c6b189b583ed80bf3483cbae95cc3fe09857e97f Mon Sep 17 00:00:00 2001 From: John60676 Date: Thu, 17 Dec 2020 15:12:57 +0800 Subject: [PATCH] fix: slider accuracy problems #3346 (#3379) --- components/vc-slider/src/utils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/vc-slider/src/utils.js b/components/vc-slider/src/utils.js index 50d345354..24e7f2708 100644 --- a/components/vc-slider/src/utils.js +++ b/components/vc-slider/src/utils.js @@ -22,7 +22,8 @@ export function isNotTouchEvent(e) { export function getClosestPoint(val, { marks, step, min, max }) { const points = Object.keys(marks).map(parseFloat); if (step !== null) { - const maxSteps = Math.floor((max - min) / step); + const base = 10 ** getPrecision(step); + const maxSteps = Math.floor((max * base - min * base) / (step * base)); const steps = Math.min((val - min) / step, maxSteps); const closestStep = Math.round(steps) * step + min; points.push(closestStep);