Yalantis/Koloda

Add `gestureRecognizer` to `shouldDragCardAt` delegate method arguments

maxydey opened this issue · 3 comments

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

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