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 806 forks source link

Add `gestureRecognizer` to `shouldDragCardAt` delegate method arguments #429

Open maxydey opened 5 years ago

maxydey commented 5 years ago

A feature request

What do you want to add?

Add gestureRecognizer to shouldDragCardAt delegate method arguments. It will make easier blocking the swipe event, when the Koloda is inside a tableviewCell, and you don't want to mess with the scroll

How should it look like?

func koloda(_ koloda: KolodaView, shouldDragCardAt index: Int, gestureRecognizer: panGestureRecognizer) -> Bool 
OmarIbbu commented 5 years ago

How to use above method

maxydey commented 5 years ago

at the moment I had to hack it like this:

    func koloda(_ koloda: KolodaView, shouldDragCardAt index: Int) -> Bool {
        let view = koloda.viewForCard(at: index)
        guard let gesture = view?.superview?.gestureRecognizers?.first(where: { $0 as? UIPanGestureRecognizer != nil }) as? UIPanGestureRecognizer else { return true }
        let translation = gesture.translation(in: nil)

        return abs(translation.y) <= abs(translation.x)
    }

My KolodaView is inside tableviewCell, so I need to prioritise the scrolling over the swiping cards, if gesture is vertical

OmarIbbu commented 5 years ago

Thanks for your kind help. I am applying shadow on the card but it is not working. WIll you please help me in this regard.

On Wed, 19 Jun 2019 at 17:40, Max notifications@github.com wrote:

at the moment I had to hack it like this:

func koloda(_ koloda: KolodaView, shouldDragCardAt index: Int) -> Bool {
    let view = koloda.viewForCard(at: index)
    guard let gesture = view?.superview?.gestureRecognizers?.first(where: { $0 as? UIPanGestureRecognizer != nil }) as? UIPanGestureRecognizer else { return true }
    let translation = gesture.translation(in: nil)

    return abs(translation.y) <= abs(translation.x)
}

My KolodaView is inside tableviewCell, so I need to prioritise the scrolling over the swiping cards, if gesture is vertical

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Yalantis/Koloda/issues/429?email_source=notifications&email_token=AGBFSWAFWLRZJHU6XPF5OV3P3IOZRA5CNFSM4HN4AXNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYBVADY#issuecomment-503533583, or mute the thread https://github.com/notifications/unsubscribe-auth/AGBFSWGXNQ3N4AZH3CR6RXDP3IOZRANCNFSM4HN4AXNA .