Skip to content
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

Can't swipe right in tinder example in docs #771

Open
jony89 opened this issue Jan 25, 2025 · 6 comments
Open

Can't swipe right in tinder example in docs #771

jony89 opened this issue Jan 25, 2025 · 6 comments
Assignees
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@jony89
Copy link

jony89 commented Jan 25, 2025

See the following tinder example of the latest docs:

https://rn-carousel.dev/Examples/custom-animations/tinder

Can't really swipe right. only left.

@jony89 jony89 added the documentation Improvements or additions to documentation label Jan 25, 2025
Copy link

dosubot bot commented Jan 25, 2025

Hey @jony89! I'm here to help you with any bugs, questions, or contributions you have in mind. Let's tackle this together!

To enable swiping right in the Tinder example from the react-native-reanimated-carousel documentation, you need to modify the fixedDirection property in the Carousel component. The current setup uses fixedDirection="negative", which restricts swiping to the left. To allow swiping right, you should remove the fixedDirection property or set it to null. Here's the relevant part of the code you need to adjust:

<Carousel
    loop={false}
    style={{
        width: PAGE_WIDTH,
        height: PAGE_HEIGHT,
        justifyContent: "center",
        alignItems: "center",
    }}
    defaultIndex={0}
    vertical={false}
    width={PAGE_WIDTH}
    height={PAGE_HEIGHT}
    data={data}
    onConfigurePanGesture={(g) => {
        g.onChange((e) => {
            "worklet";
            directionAnimVal.value = Math.sign(e.translationX);
        });
    }}
    // Remove or set fixedDirection to null to enable swiping right
    fixedDirection={null}
    renderItem={({ index, item }) => <Item key={index} img={item} />}
    customAnimation={animationStyle}
    windowSize={5}
/>

This change will allow the carousel to support swiping in both directions [1].

To continue talking to Dosu, mention @dosu.


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

@dosubot dosubot bot added the bug Something isn't working label Jan 25, 2025
@jony89
Copy link
Author

jony89 commented Jan 25, 2025

Nope changing the fixedDirection to undefined / null does not help

@dosu

@jony89
Copy link
Author

jony89 commented Jan 28, 2025

@dosu the snap does not work when swiping right

Copy link

dosubot bot commented Jan 28, 2025

To address the issue with swiping right and the snapping not working, you might want to check the onConfigurePanGesture function. Ensure that it is not disabling the gesture or affecting the swipe direction. For example, make sure that the gesture is enabled:

onConfigurePanGesture={(g) => {
    "worklet";
    g.enabled(true); // Ensure the gesture is enabled
    g.onChange((e) => {
        directionAnimVal.value = Math.sign(e.translationX);
    });
}}

Additionally, verify that the snapEnabled property is set to true, as it controls the snapping behavior:

<Carousel
    ...
    snapEnabled={true} // Ensure snapping is enabled
    ...
/>

These adjustments should help in enabling the swipe right functionality and ensure that snapping works as expected [1][2].

To continue talking to Dosu, mention @dosu.


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

@jony89
Copy link
Author

jony89 commented Jan 28, 2025

@dosu this does not change a thing

Copy link

dosubot bot commented Jan 28, 2025

Ensure that the fixedDirection property is not set, as it can restrict swipe directions. Additionally, check the pagingEnabled and snapEnabled properties. Both should be set to true to ensure proper snapping behavior:

<Carousel
    ...
    pagingEnabled={true} // Ensure paging is enabled
    snapEnabled={true}   // Ensure snapping is enabled
    ...
/>

If the issue persists, verify that there are no other configurations or custom animations affecting the swipe direction or snapping behavior. Also, ensure that the onConfigurePanGesture function is correctly enabling gestures and not interfering with the swipe logic.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | 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 documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants