We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7f718ea commit 0a600fcCopy full SHA for 0a600fc
src/utilities/normalizeSnapPoint.ts
@@ -1,3 +1,5 @@
1
+import { roundToNearestPixel } from './roundToNearestPixel';
2
+
3
/**
4
* Converts a snap point to fixed numbers.
5
*/
@@ -13,5 +15,8 @@ export const normalizeSnapPoint = (
13
15
normalizedSnapPoint =
14
16
(Number(normalizedSnapPoint.split('%')[0]) * containerHeight) / 100;
17
}
- return Math.max(0, containerHeight - normalizedSnapPoint);
18
+ return Math.max(
19
+ 0,
20
+ roundToNearestPixel(containerHeight - normalizedSnapPoint)
21
+ );
22
};
src/utilities/roundToNearestPixel.ts
@@ -0,0 +1,8 @@
+import { PixelRatio } from 'react-native';
+const PIXEL_DENSITY = PixelRatio.get();
+export function roundToNearestPixel(position: number) {
6
+ 'worklet';
7
+ return Math.round(position * PIXEL_DENSITY) / PIXEL_DENSITY;
8
+}
0 commit comments