       var maxY = statusBarHeight
       var minY = maxY - CGRectGetHeight(newFrame) + 1.0
       
-      var isScrollingAndGestureEnded =
-        (gesture.state == .Ended || gesture.state == .Cancelled) &&
-        (scrollState == .ScrollingUp || scrollState == .ScrollingDown)
-      
-      if isScrollingAndGestureEnded {
+      let isScrolling = scrollState == .ScrollingUp || scrollState == .ScrollingDown
+      gestureIsActive = gesture.state != .Ended && gesture.state != .Cancelled
+      
+      if isScrolling && !gestureIsActive {
         var contentOffsetYDelta: CGFloat = 0.0
         if scrollState == .ScrollingDown {
           contentOffsetYDelta = maxY - newFrame.origin.y


class ACScrollNavigationBar: UINavigationBar, UIGestureRecognizerDelegate {
  
  var scrollState = ACScrollNavigationBarState.None
  var lastContentOffsetY: CGFloat = 0.0
  var panGesture = UIPanGestureRecognizer()
  
  var scrollView: UIScrollView? {
    didSet {

  // MARK: Helpers
  
  func resetToDefaultPosition(animated:Bool) {
    scrollState = .None
    var defaultFrame = self.frame
    defaultFrame.origin.y = statusBarHeight()
    setFrame(defaultFrame, 1.0, animated)
