MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / ratioToValue

Function ratioToValue

core/src/components/range/range.tsx:1241–1251  ·  view source on GitHub ↗
(ratio: number, min: number, max: number, step: number)

Source from the content-addressed store, hash-verified

1239};
1240
1241const ratioToValue = (ratio: number, min: number, max: number, step: number): number => {
1242 let value = (max - min) * ratio;
1243
1244 if (step > 0) {
1245 // round to nearest multiple of step, then add min
1246 value = Math.round(value / step) * step + min;
1247 }
1248 const clampedValue = clamp(min, value, max);
1249
1250 return roundToMaxDecimalPlaces(clampedValue, min, max, step);
1251};
1252
1253const valueToRatio = (value: number, min: number, max: number): number => {
1254 return clamp(0, (value - min) / (max - min), 1);

Callers 3

updateMethod · 0.85
valAMethod · 0.85
valBMethod · 0.85

Calls 2

clampFunction · 0.90
roundToMaxDecimalPlacesFunction · 0.90

Tested by

no test coverage detected