               toView,
               belowSubview: fromView)
 
-            fadeView.alpha = 1.0
-            transactionContext.containerView.insertSubview(
-              fadeView,
-              aboveSubview: toView)
-
-            UIView.animate(withDuration: duration) {
+            toViewSnapshot.isOpaque = true
+            transactionContext.containerView.addSubview(toViewSnapshot)
+
+            fadeView.alpha = 0.0
+            transactionContext.containerView.addSubview(fadeView)
+
+            transactionContext.containerView.addSubview(fromViewSnapshot)
+
+            UIView.animate(withDuration: animationTime) {
               fadeView.alpha = 0.01
             }
 
-            fromView.drawAnimatedCircularMask(
+            fromViewSnapshot.drawAnimatedCircularMask(
               startFrame: rect,
               duration: animationTime,
               revealType: revealType) { () -> Void in
+                fromViewSnapshot.removeFromSuperview()
+                fadeView.removeFromSuperview()
+                toViewSnapshot.removeFromSuperview()
                 completion()
                 transitionCompletion?()
             }

        
        let toViewController: UIViewController? = transactionContext.viewController(
          forKey: UITransitionContextViewControllerKey.to)
        let fromViewController: UIViewController? = transactionContext.viewController(
          forKey: UITransitionContextViewControllerKey.from)
        
        if let toView: UIView = toViewController?.view,
          let fromView: UIView = fromViewController?.view {

          let fadeView: UIView = UIView(frame: fromView.frame)
          fadeView.backgroundColor = fadeColor

          toView.isOpaque = true
          fromView.isOpaque = true

          toView.layer.shouldRasterize = true
          toView.layer.rasterizationScale = UIScreen.main.scale

          fromView.layer.shouldRasterize = true
          fromView.layer.rasterizationScale = UIScreen.main.scale
          
          switch revealType {
            

              toView,
              aboveSubview: fromView)

            fromViewSnapshot.isOpaque = true
            transactionContext.containerView.addSubview(fromViewSnapshot)

            fadeView.alpha = 0.01
            transactionContext.containerView.addSubview(fadeView)

            transactionContext.containerView.addSubview(toViewSnapshot)

            UIView.animate(withDuration: animationTime) {
              fadeView.alpha = 1.0
            }

            toViewSnapshot.drawAnimatedCircularMask(
              startFrame: rect,
              duration: animationTime,
              revealType: revealType) { () -> Void in
                fromViewSnapshot.removeFromSuperview()
                fadeView.removeFromSuperview()
                toViewSnapshot.removeFromSuperview()
                completion()
                transitionCompletion?()
            }
