fix: slider accuracy problems 1.x (#3386)
* fix: slider accuracy problems * refactor: order of operationspull/3414/head
parent
ec064fe8c2
commit
6175fdbb0c
|
@ -21,7 +21,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…
Reference in New Issue