Merge pull request #1763 from Wevah/vertical-scroll-fix

Don't block vertical pan gestures
This commit is contained in:
Brent Simmons 2020-02-01 15:21:40 -08:00 committed by GitHub
commit 5d1ec3bff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);
}
}