react-native-ruler-picker
Version:
⚡ Lightning-fast and customizable Ruler Picker component for React Native
15 lines (14 loc) • 361 B
text/typescript
export const calculateCurrentValue = (
scrollPosition: number,
stepWidth: number,
gapBetweenItems: number,
min: number,
max: number,
step: number,
fractionDigits: number
) => {
const index = Math.round(scrollPosition / (stepWidth + gapBetweenItems));
return Math.min(Math.max(index * step + min, min), max).toFixed(
fractionDigits
);
};