Skip to content

Instantly share code, notes, and snippets.

@manismku
Last active December 29, 2018 14:32
Show Gist options
  • Select an option

  • Save manismku/b54080ace9e1634f5d0b940c1dcb6ae4 to your computer and use it in GitHub Desktop.

Select an option

Save manismku/b54080ace9e1634f5d0b940c1dcb6ae4 to your computer and use it in GitHub Desktop.
// MARK: - Pan
typealias HandlePanGesture = MSAlertController
extension HandlePanGesture: UIGestureRecognizerDelegate {
@objc func handlePan(sender: UIPanGestureRecognizer) {
switch sender.state {
case .began:
startLocation = sender.location(in: view)
if let direction = sender.direction {
if animator?.currentState == .closed {
if direction == .left {
animator?.setAnimation(to: .open)
}
} else {
if direction == .right {
animator?.setAnimation(to: .closed)
}
}
}
animator?.trackProgress()
case .changed:
currentLocation = sender.location(in: view)
animator?.setFractionComplete(fraction: sideGap/self.maxdx)
case .ended:
animator?.reverseAnimation(sidegap: sideGap)
animator?.completeAnimation()
break
default:
break
}
sender.setTranslation(CGPoint.zero, in: view)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment