Skip to content

Commit 44798dd

Browse files
petrkonecny2Petr Konecny
andauthored
fix: round value on go to and scroll view interaction (#27)
Co-authored-by: Petr Konecny <[email protected]>
1 parent be37b30 commit 44798dd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/components/AnimatedPagedView/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ type AnimatedPagedViewProps = {
2222
children: React.ReactNode
2323
}
2424

25+
// easiest way to allow other gestures to work, for example the scroll view
26+
const MIN_DISTANCE_THRESHOLD = 30
27+
2528
export const AnimatedPagedView = forwardRef<AnimatedPagedScrollViewRef, AnimatedPagedViewProps>(
2629
(props, ref) => {
2730
const translateX = useSharedValue(0)
@@ -38,6 +41,7 @@ export const AnimatedPagedView = forwardRef<AnimatedPagedScrollViewRef, Animated
3841
)
3942

4043
const gesture = Gesture.Pan()
44+
.minDistance(MIN_DISTANCE_THRESHOLD)
4145
.onStart(() => {
4246
context.value = { x: translateX.value }
4347
runOnJS(props.onScrollBeginDrag)()

src/hooks/useManualScroll.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const useManualScroll = ({
1616
const goToPage = useCallback(
1717
(page: number, duration = 0, animation?: typeof DEFAULT_ANIMATION) => {
1818
'worklet'
19-
const to = page * slideWidth
19+
const to = Math.round(page) * slideWidth
2020
if (duration) {
2121
manualScrollValue.value = {
2222
value: animation ? animation(to, duration) : withTiming(to, { duration }),

0 commit comments

Comments
 (0)