Skip to content

Commit

Permalink
Updating to correct conditional logic for shouldUnwind flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Øyvind Hauge committed Jan 17, 2016
1 parent 789106c commit f9b7a39
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions OHCircleSegue/OHCircleSegue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class OHCircleSegue: UIStoryboardSegue {
// Add source (or destination) controller's view to the main application
// window depending of if this is a normal or unwind segue
let window = UIApplication.sharedApplication().keyWindow
if shouldUnwind {
if !shouldUnwind {
window?.insertSubview(destView, aboveSubview: sourceView)
} else {
window?.insertSubview(destView, atIndex:0)
Expand All @@ -58,16 +58,16 @@ class OHCircleSegue: UIStoryboardSegue {
mask.anchorPoint = CGPoint(x: 0.5, y: 0.5)
mask.position = circleOrigin
mask.path = paths.start
(shouldUnwind ? destView : sourceView).layer.mask = mask
(shouldUnwind ? sourceView : destView).layer.mask = mask

// Call method for creating animation and add it to the view's mask
(shouldUnwind ? destView : sourceView).layer.mask?.addAnimation(scalingAnimation(paths.end), forKey: nil)
(shouldUnwind ? sourceView : destView).layer.mask?.addAnimation(scalingAnimation(paths.end), forKey: nil)
}

// MARK: Animation delegate

override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
if shouldUnwind {
if !shouldUnwind {
sourceViewController.presentViewController(destinationViewController, animated: false, completion: nil)
} else {
sourceViewController.dismissViewControllerAnimated(false, completion: nil)
Expand All @@ -82,7 +82,7 @@ class OHCircleSegue: UIStoryboardSegue {
animation.toValue = destinationPath
animation.removedOnCompletion = false
animation.fillMode = kCAFillModeBoth
animation.duration = shouldUnwind ? expandDur : contractDur
animation.duration = shouldUnwind ? contractDur : expandDur
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
animation.delegate = self
return animation
Expand Down

0 comments on commit f9b7a39

Please sign in to comment.