mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add some tolerance to the swipe back gesture
This commit is contained in:
parent
cdc9901f71
commit
9c9b91d853
1 changed files with 8 additions and 8 deletions
|
|
@ -80,15 +80,14 @@
|
|||
@objc func handlePanGesture(_ panGesture: UIPanGestureRecognizer) {
|
||||
// if the parentNavigationControllerToUse has a width value, use that because it's more accurate. Otherwise use this view's width as a backup
|
||||
let total = parentNavigationControllerToUse?.view.frame.width ?? view.frame.width
|
||||
let percent = max(panGesture.translation(in: view).x, 0) / total
|
||||
let amount = max(panGesture.translation(in: view).x, 0)
|
||||
let percent = amount / total
|
||||
let velocity = panGesture.velocity(in: view).x
|
||||
|
||||
switch panGesture.state {
|
||||
case .began:
|
||||
if lazyPopContent?.isEnabled == true {
|
||||
parentNavigationControllerToUse?.delegate = self
|
||||
if let pop = self.pop {
|
||||
pop()
|
||||
}
|
||||
}
|
||||
|
||||
case .changed:
|
||||
|
|
@ -97,10 +96,11 @@
|
|||
}
|
||||
|
||||
case .ended:
|
||||
let velocity = panGesture.velocity(in: view).x
|
||||
|
||||
// Continue if drag more than 50% of screen width or velocity is higher than 100
|
||||
if percent > 0.5 || velocity > 100 {
|
||||
// Continue if drag more than 20% of screen width or velocity is higher than 1000
|
||||
if percent > 0.2 || velocity > 1000 {
|
||||
if let pop = self.pop {
|
||||
pop()
|
||||
}
|
||||
percentDrivenInteractiveTransition?.finish()
|
||||
} else {
|
||||
percentDrivenInteractiveTransition?.cancel()
|
||||
|
|
|
|||
Loading…
Reference in a new issue