MCPcopy
hub / github.com/DavidHDev/react-bits / stepDecimals

Function stepDecimals

src/components/common/Preview/PreviewSlider.jsx:5–9  ·  view source on GitHub ↗
(step)

Source from the content-addressed store, hash-verified

3
4const clamp = (val, min, max) => Math.min(Math.max(val, min), max);
5const stepDecimals = (step) => {
6 const s = step.toString();
7 const dot = s.indexOf('.');
8 return dot === -1 ? 0 : s.length - dot - 1;
9};
10const roundToStep = (val, step, min) => {
11 const raw = Math.round((val - min) / step) * step + min;
12 const decimals = Math.max(stepDecimals(step), stepDecimals(min));

Callers 2

roundToStepFunction · 0.70
PreviewSliderFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected