diff --git a/src/utilities/normalizeSnapPoint.ts b/src/utilities/normalizeSnapPoint.ts index 46745dbf..a54d1297 100644 --- a/src/utilities/normalizeSnapPoint.ts +++ b/src/utilities/normalizeSnapPoint.ts @@ -1,3 +1,12 @@ +import { PixelRatio } from 'react-native'; + +const PIXEL_DENSITY = PixelRatio.get(); + +function roundToNearestPixel(position: number) { + 'worklet'; + return Math.round(position * PIXEL_DENSITY) / PIXEL_DENSITY; +} + /** * Converts a snap point to fixed numbers. */ @@ -13,5 +22,8 @@ export const normalizeSnapPoint = ( normalizedSnapPoint = (Number(normalizedSnapPoint.split('%')[0]) * containerHeight) / 100; } - return Math.max(0, containerHeight - normalizedSnapPoint); + return Math.max( + 0, + roundToNearestPixel(containerHeight - normalizedSnapPoint) + ); };