Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(value: number) => {
let nextValue = value;
nextValue = +roundValueToStep(nextValue, keyStep);
nextValue = constrainValue(nextValue, min, max);
updateValue(nextValue);
},
[keyStep, max, min, updateValue],
const { clientX, clientY } = event;
let diff = isVertical
? trackRect.bottom - clientY
: clientX - trackRect.left;
const length = isVertical ? trackRect.height : trackRect.width;
let percent = diff / length;
if (isReversed) {
percent = 1 - percent;
}
let nextValue = percentToValue(percent, min, max);
if (step) {
nextValue = +roundValueToStep(nextValue, step);
}
nextValue = constrainValue(nextValue, min, max);
return nextValue;
}
},
[isVertical, isReversed, max, min, step],