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