         self.transitionType = transitionType
     }
 
-}
-
-// MARK: - View Controller Animated Transitioning Protocol
+    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 {
 

            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()
                    }
            }
    }


    }

}

extension SplitTransition: UIGestureRecognizerDelegate {

    public func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
        let location = gestureRecognizer.locationInView(container)
        let presentationLayer = container?.layer.presentationLayer()

        if ((presentationLayer?.hitTest(location)) != nil) {
            return true
        }
        return false
    }
    
}

extension SplitTransition: UIViewControllerTransitioningDelegate {
    
    public func interactionControllerForPresentation(animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
        return interactive ? self : nil
    }
    
    public func interactionControllerForDismissal(animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
        return interactive ? self : nil
    }
    
}
