UNPKG

@gorhom/bottom-sheet

Version:

A performant interactive bottom sheet with fully configurable options 🚀

12 lines (11 loc) • 337 B
export const snapPoint = ( value: number, velocity: number, points: ReadonlyArray<number> ): number => { 'worklet'; const point = value + 0.2 * velocity; const deltas = points.map(p => Math.abs(point - p)); const minDelta = Math.min.apply(null, deltas); return points.filter(p => Math.abs(point - p) === minDelta)[0]; };