 
         let maskLayerAnimation = CABasicAnimation(keyPath: "path")
         maskLayerAnimation.fromValue = initialMaskPath.CGPath
-        maskLayerAnimation.toValue = finalMaskPath.CGPath
+        maskLayerAnimation.toValue = initialMaskPath.CGPath
         maskLayerAnimation.duration = transitionDuration(transitionContext)
         maskLayerAnimation.delegate = self
         maskLayerAnimation.removedOnCompletion = true
         maskLayer.addAnimation(maskLayerAnimation, forKey: "path")
 
+
+        let fullDuration = transitionDuration(transitionContext)
+
+        if let transitionView = transitionView {
+
+            UIView.animateKeyframesWithDuration(fullDuration, delay: 0.0, options: .CalculationModeCubic, animations: { () -> Void in
+
+                UIView.addKeyframeWithRelativeStartTime(0.0, relativeDuration: 0.2, animations: { () -> Void in
+                    let ratio = (animatingView.bounds.width + self.largerOffset) / animatingView.bounds.width
+                    fromVC?.mediaView.transform = CGAffineTransformMakeScale(ratio, ratio)
+                })
+
+                UIView.addKeyframeWithRelativeStartTime(0.2, relativeDuration: 0.0, animations: { () -> Void in
+                    animatingView.addSubview(transitionView)
+                    transitionView.center = animatingView.center
+                    transitionView.alpha = 1
+
+                    fromVC?.mediaView.alpha = 0
+                })
+
+                UIView.addKeyframeWithRelativeStartTime(0.2, relativeDuration: 0.5, animations: { () -> Void in
+                    transitionView.frame = self.frame
+                })
+
+                UIView.addKeyframeWithRelativeStartTime(0.7, relativeDuration: 0.3, animations: { () -> Void in
+                    animatingVC.view.backgroundColor = UIColor.clearColor()
+                })
+
+            }, completion: { (finished) -> Void in
+                transitionView.removeFromSuperview()
+            })
+        }
 
     }
 

        maskLayer.addAnimation(maskLayerAnimation, forKey: "path")



        if let transitionView = transitionView {
            animatingView.addSubview(transitionView)
            transitionView.frame = frame

                })

                UIView.addKeyframeWithRelativeStartTime(0.9, relativeDuration: 0.0, animations: { () -> Void in
                    let ratio = (animatingView.bounds.width + self.largerOffset) / animatingView.bounds.width
                    toVC?.mediaView.transform = CGAffineTransformMakeScale(ratio, ratio)
                    toVC?.mediaView.alpha = 1
                    transitionView.alpha = 0
