Yalantis / Koloda

KolodaView is a class designed to simplify the implementation of Tinder like cards on iOS.

Home Page:https://yalantis.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add `gestureRecognizer` to `shouldDragCardAt` delegate method arguments

maxydey opened this issue · comments

commented

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 

How to use above method

commented

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