Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save RaajeevChandran/836b5ae7fc21f5da8beec5f306b846d8 to your computer and use it in GitHub Desktop.

Select an option

Save RaajeevChandran/836b5ae7fc21f5da8beec5f306b846d8 to your computer and use it in GitHub Desktop.
@objc private func pannedPresentedView(_ recognizer: UIPanGestureRecognizer) {
guard let presentedView = presentedView else {
return
}
switch recognizer.state {
case .began:
transitioningDelegate?.transition.wantsInteractiveStart = true
case .changed:
let translation = recognizer.translation(in: presentedView)
didGestureTranslationChange(translation)
case .ended:
let translation = recognizer.translation(in: presentedView)
let progress = translation.y / presentedView.frame.height
if progress > dismissThreshold {
dismiss(withInteraction: true)
transitioningDelegate?.transition.finish()
} else {
UIView.animate(withDuration: 0.2) {
presentedView.transform = .identity
}
transitioningDelegate?.transition.cancel()
}
case .cancelled, .failed:
break
default:
break
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment