Yalantis / Koloda

KolodaView is a class designed to simplify the implementation of Tinder like cards on iOS.
https://yalantis.com
MIT License
5.37k stars 805 forks source link

Question: How to allow / disallow swiping of cards? #135

Closed gerardo-navarro closed 8 years ago

gerardo-navarro commented 8 years ago

Hi Guys,

I'd like to be able to decide whether a card can be swiped or not. I expected to find something, but could not find it in the current version 2.0.10: func koloda(koloda: KolodaView, shouldBeSwipedCardAtIndex index: UInt, inDirection direction: SwipeResultDirection) -> Bool

Do you have some suggestions for how to implement this with the current implementation?

Cheers Gerardo

tomekh7 commented 8 years ago

One of possible solutions could be disabling/enabling user interactions on kolodaView for particular cards.

gerardo-navarro commented 8 years ago

Thanks for the answer. This is a valid solution as long as the card is not being dragged.

However, I refer to the situation where the card is being dragged and I'd like to decide whether it can swiped away completely or not.

AEugene commented 8 years ago

@gerardo-navarro That's a good idea! I'll implement it )

felix-dumit commented 8 years ago

@AEugene I added this to my PR #131 as I needed to use that in a project, you can extract the relevant part into the code if you'd like.

briansunter commented 8 years ago

I would also be interested in preventing the cards from moving at all. In my own case I would like to keep the "tapped card" event enabled, but prevent the cards from moving

briansunter commented 8 years ago

I needed this for my own project so I opened a pull request. I wanted to preserve user interaction on the card itself and preserve the built in "tapped card" event, but prevent the card from moving at all until certain conditions were met.

https://github.com/Yalantis/Koloda/pull/142