Skip to content

Commit

Permalink
fix: slider accuracy problems vueComponent#3346 (vueComponent#3379)
Browse files Browse the repository at this point in the history
  • Loading branch information
John60676 authored Dec 17, 2020
1 parent 184fe68 commit c6b189b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/vc-slider/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c6b189b

Please sign in to comment.