@gorhom/bottom-sheet
Version:
A performant interactive bottom sheet with fully configurable options 🚀
18 lines (16 loc) • 448 B
text/typescript
/**
* Converts a snap point to fixed numbers.
*/
export const normalizeSnapPoint = (
snapPoint: number | string,
containerHeight: number
) => {
'worklet';
let normalizedSnapPoint = snapPoint;
// percentage snap point
if (typeof normalizedSnapPoint === 'string') {
normalizedSnapPoint =
(Number(normalizedSnapPoint.split('%')[0]) * containerHeight) / 100;
}
return Math.max(0, containerHeight - normalizedSnapPoint);
};