Skip to content

Commit

Permalink
MarioIannotta#60 - Allows horizontal swipe on the table cells
Browse files Browse the repository at this point in the history
This solve issue MarioIannotta#60
  • Loading branch information
AndreaMiotto authored Jun 3, 2019
1 parent dfb0534 commit bd5ce09
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions PullUpController/PullUpController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ open class PullUpController: UIViewController {
panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(handlePanGestureRecognizer(_:)))
panGestureRecognizer?.minimumNumberOfTouches = 1
panGestureRecognizer?.maximumNumberOfTouches = 1
panGestureRecognizer?.delegate = self
if let panGestureRecognizer = panGestureRecognizer {
view.addGestureRecognizer(panGestureRecognizer)
}
Expand Down Expand Up @@ -363,6 +364,10 @@ open class PullUpController: UIViewController {
let topConstraint = topConstraint
else { return }

let xVelocity = gestureRecognizer.velocity(in: self.view).x
let xTranslation = gestureRecognizer.translation(in: view).x
if abs(xVelocity) > 0 || abs(xTranslation) > 0 { return }

let yTranslation = gestureRecognizer.translation(in: view).y

switch gestureRecognizer.state {
Expand Down Expand Up @@ -513,6 +518,19 @@ extension UIViewController {

}

extension PullUpController: UIGestureRecognizerDelegate {

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {

guard let _ = otherGestureRecognizer as? UIPanGestureRecognizer, let current = gestureRecognizer as? UIPanGestureRecognizer else {
return false
}

let velocity = current.velocity(in: self.view)
return abs(velocity.x) >= abs(velocity.y);
}
}

extension UIScrollView {

/**
Expand Down

0 comments on commit bd5ce09

Please sign in to comment.