swaplet / react-native-swipe-cards-deck

A swipping cards deck (similar to Tinder)
MIT License
46 stars 19 forks source link

not working properly with scrollview #8

Closed mirza-osv closed 3 years ago

mirza-osv commented 3 years ago

Swiping card gets stuck in the middle if using scrollview

eyalabs commented 3 years ago

Sorry, but this is not supported and will not be supported as it is bad UX practice.

You should always avoid using 2 "scrollables" within each other even if they work in different "directions". There is an acceptable case when you use an horizontal scrollable within a vertical one but in the case of cards, they are swappable in x & y axis this causes conflicts with other scrollable parent.

mirza-osv commented 3 years ago

I just want to swipe either left side or right side, so If I choose horizontal scroll for this, will it work? I have a long screen in which swipe cards are top position and it needs scrollview mandatorily

eyalabs commented 3 years ago

Try using dragY=false prop. When I tested it it didn't work #4.

I didn't fix it because there isn't enough demand.

mirza-osv commented 3 years ago

Yeah, I too tested with dragY=false but it doesn't work

mirza-osv commented 3 years ago

I have been using react-native-deck-swiper and it is well support in ScrollView. However, the issue there is It is swiping two cards with one swipe which is bizarre.

eyalabs commented 3 years ago

fixed in latest ver #4

mirza-osv commented 3 years ago

@eyalabs I just updated the latest one but cards still getting stuck while scrolling vertically in the content even with dragY = {false} Do we have any method which can be called while onSwiping so that I can disable scrolling

eyalabs commented 3 years ago

Please attach a gif of the problem

mirza-osv commented 3 years ago

Here is the GIF link https://gifyu.com/image/ZfQC [sorry image is a bit slow but consider that as normal]

Code

<ScrollView onScroll={this.onScroll} scrollEventThrottle={32}>
                <View style={{ minHeight: 500 }}>
                    <SwipeCards
                        dragY={false}
                        cards={this.state.cards}
                        renderCard={cardData => <Card {...cardData} />}
                        renderNoMoreCards={() => <NoMoreCards />}
                        handleYup={this.handleYup}
                        handleNope={this.handleNope}
                        handleMaybe={this.handleMaybe}
                        stack={true}
                    />
                </View>
                <View>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                    <Text>test</Text>
                </View>
            </ScrollView>
eyalabs commented 3 years ago

I tested it with:

<ScrollView scrollEventThrottle={32}>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Cards />
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
        <Text>test</Text>
      </ScrollView>

And it works fine. And as I said before, this is bad design - there will be conflicts. Maybe your problem is with <ScrollView onScroll={this.onScroll} scrollEventThrottle={32}>.

ezgif-6-1b35d04a8f51.gif

mirza-osv commented 3 years ago

This definitely works fine without <ScrollView/> If my screen is long enough I will have no choice to scroll except using <ScrollView>. Can you suggest something? Basically the issue arises when you begin to scroll while swiping.

eyalabs commented 3 years ago

You can see from the code that I did exactly as you did, just removed onScroll={this.onScroll} from the ScrollView. Please look at my test code and the gif, both are the result of using ScrollView

mirza-osv commented 3 years ago

I've remove onScroll={this.onScroll} but still same response. Can you just half drag, scroll and leave your mouse you will surely notice that card get stuck

eyalabs commented 3 years ago

This happens only for iOS. On Android it works great. What I suggest is that you use allowGestureTermination={false} in the swipe cards. This fixes the problem for iOS.

mirza-osv commented 3 years ago

Thank you this have fixed the issue for me. Is there any way to reduce the sensitivity of swiping? As I scrolling (without swiping), somewhere it is touching the swiping items and slightly its moving right-left

eyalabs commented 3 years ago

@mirza-osv check #10 - it will be included in v3.0