UNPKG

react-native-ui-lib

Version:

<p align="center"> <img src="https://user-images.githubusercontent.com/1780255/105469025-56759000-5ca0-11eb-993d-3568c1fd54f4.png" height="250px" style="display:block"/> </p> <p align="center">UI Toolset & Components Library for React Native</p> <p a

23 lines (19 loc) 419 B
export default (({ itemHeight, listSize }) => { const valueInRange = (value, min, max) => { if (value < min || value === -0) { return min; } if (value > max) { return max; } return value; }; const middleIndex = offset => { const calculatedIndex = Math.round(offset / itemHeight); return valueInRange(calculatedIndex, 0, listSize - 1); }; return middleIndex; });