         finishInteractiveTransition()
       }
     default:
+      // Something happened. cancel the transition.
+      cancelInteractiveTransition()
       break
     }
   }

      return
    }
    let translation = gestureRecognizer.translationInView(superview)
    
    // width or heigth depends on the gesture direction
    let distance: CGFloat
    switch interactiveGestureType {
    case .PanHorizontally, .PanFromLeft, .PanFromRight:
      distance = superview.frame.width
    case .PanVertically, .PanFromTop, .PanFromBottom:
      distance = superview.frame.height
    default:
      return
    }
    
    var progress: CGFloat = abs(translation.x / distance)
    progress = min(max(progress, 0.01), 0.99)

    switch gestureRecognizer.state {
    case .Began:

    super.init()
  }
  
  deinit {
    gestureRecognizer?.removeTarget(self, action: Selector("handleGesture:"))
  }
  
  func connectGestureRecognizer(viewController: UIViewController) {
    self.viewController = viewController
    gestureRecognizer = UIPanGestureRecognizer(target: self, action: Selector("handleGesture:"))
