         return transitionContext?.containerView()
     }
 
+    func setupTransition(transitionContext: UIViewControllerContextTransitioning?) -> Void {
+        // Take screenshot and store resulting UIImage
+        screenCapture = UIWindow.screenShot()
+
+        // Grab the view in which the transition should take place.
+        // Coalesce to UIView()
+        container = containerView(transitionContext) ?? UIView()
+
+        // Set source and destination view controllers
+        fromVC = fromViewController(transitionContext) ?? UIViewController()
+        toVC = toViewController(transitionContext) ?? UIViewController()
+
+        // Set completion handler for transition
+        completion = {
+            let complete: Bool = transitionContext?.transitionWasCancelled() ?? false
+            // Remove gesture recognizer from view
+            if let gestureRecognizer = self.gestureRecognizer {
+                gestureRecognizer.view?.removeGestureRecognizer(gestureRecognizer)
+            }
+
+            // Complete the transition
+            transitionContext?.completeTransition(!complete)
+            transitionContext?.finishInteractiveTransition()
+        }
+    }
+
     // Push Transition
-    func push(toViewController: UIViewController,
+    func push(toOffset: CGFloat = 0.0, toViewController: UIViewController,
         fromViewController: UIViewController,
         containerView: UIView,
         completion: (() -> ())?) {

            toViewController.view.alpha = 1.0
            toViewController.view.transform = CGAffineTransformMakeTranslation(0.0, topSplitImageView.frame.size.height)

            UIView.animateWithDuration(transitionDuration, delay: 0.0, usingSpringWithDamping: 0.65, initialSpringVelocity: 1.0, options: .LayoutSubviews, animations: { [weak self] () -> Void in
                if let controller = self {
                    controller.topSplitImageView.transform = CGAffineTransformMakeTranslation(0.0, -controller.topSplitImageView.bounds.size.height)
                    controller.bottomSplitImageView.transform = CGAffineTransformMakeTranslation(0.0, controller.bottomSplitImageView.bounds.size.height)
                    toViewController.view.transform = CGAffineTransformIdentity
                }
                }) { [weak self] (Bool) -> Void in
                    // When the transition is finished, top and bottom
                    // split views are removed from the view hierarchy
                    if let controller = self {
                        controller.topSplitImageView.removeFromSuperview()
                        controller.bottomSplitImageView.removeFromSuperview()
                    }

                    // If a completion was passed as a parameter,
                    // execute it
                    if let completion = completion {
                        completion()
                    }
            }
    }


        self.transitionType = transitionType
    }

    func didPan(gesture: UIPanGestureRecognizer) {

        switch (gesture.state) {
        case .Began:
            let presentationLayer = container?.layer.presentationLayer()
            container?.layer.position = presentationLayer?.position ?? CGPointZero
            container?.layer.removeAllAnimations()
            previousTouchLocation = gesture.locationInView(container)
            break
        case .Changed:
            let currentTouchLocation = gesture.locationInView(container)
            let distanceMoved = currentTouchLocation.y - previousTouchLocation.y

            transitionProgress += distanceMoved
            let totalDistance = max(topSplitImageView.bounds.size.height, bottomSplitImageView.bounds.size.height)

            let floor = canScrollToZero ? 0.0 : 50.0 / totalDistance

            // Update interactive transition
            let percentComplete = max((transitionProgress / totalDistance), floor)

            print("\(previousTouchLocation.y > currentTouchLocation.y)")
            if (previousTouchLocation.y > currentTouchLocation.y) && percentComplete == floor {
                canScrollToZero = true
            }

            print("\(percentComplete)")
            previousTouchLocation = currentTouchLocation

            transitionProgress += ((currentTouchLocation.y - splitLocation) / splitLocation)
            topSplitImageView.transform = CGAffineTransformMakeTranslation(0.0, -(percentComplete * (topSplitImageView.bounds.size.height - 50.0)))
            bottomSplitImageView.transform = CGAffineTransformMakeTranslation(0.0, (percentComplete * (bottomSplitImageView.bounds.size.height - 50.0)))

            transitionContext?.updateInteractiveTransition(percentComplete)

            if (percentComplete >= 1.0) {
                // When the transition is finished, top and bottom
                // split views are removed from the view hierarchy
                topSplitImageView.removeFromSuperview()
                bottomSplitImageView.removeFromSuperview()
                if let completion = completion {
                    completion()
                }

                // Make destination view controller's view visible again
                toVC?.view.alpha = 1.0
                fromVC?.view.alpha = 0.0
            }
            else if (percentComplete == 0.0) {
                topSplitImageView.removeFromSuperview()
                bottomSplitImageView.removeFromSuperview()
                if let completion = completion {
                    cancelInteractiveTransition()
                    completion()
                }

                // Make destination view controller's view visible again
                toVC?.view.alpha = 0.0
                if let destinationView = fromVC?.view,
                    originView = toVC?.view {
                        container?.insertSubview(destinationView, aboveSubview: originView)
                        destinationView.alpha = 1.0
                }
                canScrollToZero = false
            }
            break
        default:
            break
        }
    }

    public override func startInteractiveTransition(transitionContext: UIViewControllerContextTransitioning) {
        setupTransition(transitionContext)
    }

}

extension SplitTransition: UIViewControllerAnimatedTransitioning {

