Skip to content

Commit c6b189b

Browse files
authored
fix: slider accuracy problems vueComponent#3346 (vueComponent#3379)
1 parent 184fe68 commit c6b189b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

components/vc-slider/src/utils.js

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

0 commit comments

Comments
 (0)