Skip to content

Commit 6175fdb

Browse files
authored
fix: slider accuracy problems 1.x (#3386)
* fix: slider accuracy problems * refactor: order of operations
1 parent ec064fe commit 6175fdb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: components/vc-slider/src/utils.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export function isNotTouchEvent(e) {
2121
export function getClosestPoint(val, { marks, step, min, max }) {
2222
const points = Object.keys(marks).map(parseFloat);
2323
if (step !== null) {
24-
const maxSteps = Math.floor((max - min) / step);
24+
const base = 10 ** getPrecision(step);
25+
const maxSteps = Math.floor((max * base - min * base) / (step * base));
2526
const steps = Math.min((val - min) / step, maxSteps);
2627
const closestStep = Math.round(steps) * step + min;
2728
points.push(closestStep);

0 commit comments

Comments
 (0)