From f334b7e7806ea8f82db5a214be2da66a3840371d Mon Sep 17 00:00:00 2001 From: John Date: Wed, 16 Dec 2020 15:16:10 +0800 Subject: [PATCH] fix: slider accuracy problems #3346 --- 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 50d3453544..24e7f27082 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);