Browse Source

fix: slider accuracy problems #3346 (#3379)

pull/3392/head
John60676 4 years ago committed by GitHub
parent
commit
c6b189b583
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      components/vc-slider/src/utils.js

3
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);

Loading…
Cancel
Save