remove self.

This commit is contained in:
Scott Pfeil 2021-12-20 14:45:14 -05:00
parent 9aad8e897c
commit 15d60bd3eb
2 changed files with 26 additions and 26 deletions

View File

@ -45,11 +45,11 @@ fileprivate enum SubNavPanningDirection : Int {
}
public init(viewController: UIViewController, delegate: SubNavSwipeNavigationProtocol) {
self.pannablePercentage = 0.15
pannablePercentage = 0.15
self.delegate = delegate
super.init()
self.panGesture = UIPanGestureRecognizer.init(target: self, action: #selector(handlePanGesture));
viewController.view.addGestureRecognizer(self.panGesture)
panGesture = UIPanGestureRecognizer.init(target: self, action: #selector(handlePanGesture));
viewController.view.addGestureRecognizer(panGesture)
}
//overrides
@ -91,20 +91,20 @@ fileprivate enum SubNavPanningDirection : Int {
case .began:
// Begin the transition to the next page.
self.panning = true
panning = true
if velocityX < 0 && pannableFrameRight.contains(locationInView) {
self.delegate?.swipeLeft()
self.panningDirection = .left
delegate?.swipeLeft()
panningDirection = .left
} else if velocityX > 0 && pannableFrameLeft.contains(locationInView){
self.delegate?.swipeRight()
self.panningDirection = .right
delegate?.swipeRight()
panningDirection = .right
}
case .changed:
guard self.interactive else { return }
guard interactive else { return }
if self.panningDirection == .right && translation.x < 0 ||
self.panningDirection == .left && translation.x > 0 {
if panningDirection == .right && translation.x < 0 ||
panningDirection == .left && translation.x > 0 {
percentage = 0
}
@ -114,27 +114,27 @@ fileprivate enum SubNavPanningDirection : Int {
if percentage > 1.00 {
percentage = 1.00;
}
self.shouldCompleteTransition = percentage > 0.65;
self.update(percentage)
self.delegate?.update(percentage: percentage)
shouldCompleteTransition = percentage > 0.65;
update(percentage)
delegate?.update(percentage: percentage)
case .cancelled:
self.cancel()
cancel()
case .ended:
if ((percentage < 0) != (velocityX < 0)) && abs(velocityX) > 50 {
// If we are moving back toward the previous view we want to cancel. (the speed threshold is for shaky hands)
self.cancel()
cancel()
} else if abs(velocityX) > 300.0 || shouldCompleteTransition {
// Need to cancel the transition if we pass the threshold, but from a opposite direction(e.g. Start panning from left edge to right, then move back, pass the start x location, end with a high velocityX)
if ((panningDirection == .right) && translation.x < 0) || ((panningDirection == .left) && translation.x > 0) {
self.cancel()
cancel()
} else {
// If we pass the speed or screen percentage thresholds, move on to the next screen.
self.finish()
finish()
}
} else {
self.cancel()
cancel()
}
default:

View File

@ -23,25 +23,25 @@ import MVMCore
}
public func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
self.animationTime = 0.5
return self.animationTime
animationTime = 0.5
return animationTime
}
public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
self.controller?.view.isUserInteractionEnabled = false
controller?.view.isUserInteractionEnabled = false
let containerView = transitionContext.containerView
guard let originalViewController = transitionContext.viewController(forKey: .from),
let destinationViewController = transitionContext.viewController(forKey: .to) else { return }
var destStartFrame = containerView.bounds
destStartFrame.origin.x = self.direction == .right ? -destStartFrame.size.width : destStartFrame.size.width
destStartFrame.origin.x = direction == .right ? -destStartFrame.size.width : destStartFrame.size.width
containerView.addSubview(destinationViewController.view)
destinationViewController.view.frame = destStartFrame
let destEndFrame = containerView.bounds
var origEndFrame = containerView.bounds
origEndFrame.origin.x = self.direction == .right ? origEndFrame.size.width : -origEndFrame.size.width
origEndFrame.origin.x = direction == .right ? origEndFrame.size.width : -origEndFrame.size.width
UIView.animate(withDuration: animationTime, animations: {
originalViewController.view.frame = origEndFrame
@ -53,8 +53,8 @@ import MVMCore
public func animationEnded(_ transitionCompleted: Bool) {
if !transitionCompleted {
self.interactiveTransitionCanceled = true
interactiveTransitionCanceled = true
}
self.controller?.view.isUserInteractionEnabled = true
controller?.view.isUserInteractionEnabled = true
}
}