Skip to content

Swipe range is very small when running on IOS #799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
huybui21 opened this issue Mar 24, 2025 · 1 comment
Open

Swipe range is very small when running on IOS #799

huybui21 opened this issue Mar 24, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@huybui21
Copy link

<View style={{ flex: 1, marginTop: Platform.OS == 'android' ? height / 8 : height / 6.5, marginBottom: 40, borderRadius: 10, }} > <Carousel loop width={width * 1} height={width / 2} autoPlay autoPlayInterval={5000} data={images} renderItem={({ item }) => ( <Pressable style={styles.banner} onPress={() => navigation.navigate('Banner')}> <Image source={item} style={styles.imgBanner} /> </Pressable> )} /> </View>

I am using:
"react-native-gesture-handler": "~2.20.2",
"react-native-reanimated": "~3.16.1",
"react-native-reanimated-carousel": "^4.0.2",

When I do a horizontal swipe on android everything works fine. For IOS the range that can be swiped and right pressed is around the top of the photo

@huybui21 huybui21 added the bug Something isn't working label Mar 24, 2025
Copy link

dosubot bot commented Mar 24, 2025

To address the issue of a small swipe range on iOS with the react-native-reanimated-carousel, you can try adjusting the windowSize parameter in the useVisibleRanges hook. Increasing the windowSize can effectively increase the swipe range by allowing more items to be considered within the swipe range.

Here's an example of how you might adjust the windowSize:

import { useVisibleRanges } from 'path-to-useVisibleRanges';

const totalItems = images.length; // Total number of items in the carousel
const viewSize = width; // Size of each view/item
const translation = useSharedValue(0); // Shared value for translation

const visibleRanges = useVisibleRanges({
  total: totalItems,
  viewSize: viewSize,
  windowSize: 5, // Increase this value to increase the swipe range
  translation: translation,
  loop: true, // Set to true if you want the carousel to loop
});

Additionally, you might want to explore the maxScrollDistancePerSwipe prop, which can limit the maximum distance the carousel can scroll in a single swipe. Adjusting this prop might also help in achieving the desired swipe behavior on iOS [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants