Don't block vertical pan gestures

This commit is contained in:
Nate Weaver 2020-02-01 01:12:54 -06:00
parent 2f9506a8b8
commit b86341f44c

View File

@ -215,7 +215,9 @@ class MasterFeedViewController: UITableViewController, UndoableCommandRunner {
headerView.addGestureRecognizer(tap)
// Without this the swipe gesture registers on the cell below
headerView.addGestureRecognizer(UIPanGestureRecognizer(target: nil, action: nil))
let gestureRecognizer = UIPanGestureRecognizer(target: nil, action: nil)
gestureRecognizer.delegate = self
headerView.addGestureRecognizer(gestureRecognizer)
headerView.interactions.removeAll()
if section != 0 {
@ -1229,3 +1231,13 @@ private extension MasterFeedViewController {
}
}
extension MasterFeedViewController: UIGestureRecognizerDelegate {
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
guard let gestureRecognizer = gestureRecognizer as? UIPanGestureRecognizer else {
return false
}
let velocity = gestureRecognizer.velocity(in: self.view)
return abs(velocity.x) > abs(velocity.y);
}
}