 
         if var viewCenter = pan.view?.center {
             if pan.state == .Began || pan.state == .Changed {
+                
                 let translation = pan.translationInView(pan.view!.superview!)
-                if viewCenter.y >= UIScreen.mainScreen().bounds.size.height/2 && viewCenter.y <= (UIScreen.mainScreen().bounds.size.height/2 + height!) - bounceOffset {
+                if viewCenter.y >= UIScreen.mainScreen().bounds.size.height/2
+                    && viewCenter.y <= (UIScreen.mainScreen().bounds.size.height/2 + height!) - bounceOffset {
+                            
                     currentState = .Displaying
                     viewCenter.y = abs(viewCenter.y + translation.y)
-                    if viewCenter.y >= UIScreen.mainScreen().bounds.size.height/2 && viewCenter.y <= (UIScreen.mainScreen().bounds.size.height/2 + height!) - bounceOffset {
+                    if viewCenter.y >= UIScreen.mainScreen().bounds.size.height/2
+                        && viewCenter.y <= (UIScreen.mainScreen().bounds.size.height/2 + height!) - bounceOffset {
+
                         contentController?.view.center = viewCenter
                     }
                     pan.setTranslation(CGPointZero, inView: contentController?.view)
                 }
+                
             } else if pan.state == .Ended {
+
                 let velocity = pan.velocityInView(contentController?.view.superview)
                 if velocity.y > velocityTreshold {
                     openMenuFromCenterWithVelocity(velocity.y)


    public var height: CGFloat? {
        willSet {
            var menuFrame = frame
            menuFrame.size.height = newValue!
            menuContentTable?.frame = menuFrame
            self.height = newValue


    //MARK:Animation and menu operations

    public func menuOpening(#animated: Bool) {
        if currentState != .Shown {
            showStatusBar()
            if let x = contentController?.view.center.x {
                
                UIView.animateWithDuration(0.2, animations: {[unowned self]() -> Void in
                    
                    self.contentController?.view.center = CGPointMake(x, UIScreen.mainScreen().bounds.size.height/2 + self.height!)
                    
                }, completion: {[unowned self](finished: Bool) -> Void in
                    
                    UIView.animateWithDuration(0.2, animations: {[unowned self]() -> Void in
                        self.contentController?.view.center = CGPointMake(x, UIScreen.mainScreen().bounds.size.height/2 + self.height! - bounceOffset)
                    }, completion: {(finished: Bool) -> Void in
                        self.currentState = .Shown
                    })

                })
            }
        }
    }
    
    public func menuClosingWithCompletion(#animated:Bool, completion: completionHandler?) {
        dismissStatusBar()
        if let center = contentController?.view.center {
            
            if animated {
                UIView.animateWithDuration(0.2, animations: {[unowned self] in
                    self.contentController?.view.center = CGPointMake(center.x, center.y + bounceOffset)
                    
                    }, completion: {[unowned self](finished: Bool) -> Void in
                        
                        UIView.animateWithDuration(0.2, animations: {[unowned self] in
                            self.contentController?.view.center = CGPointMake(center.x, UIScreen.mainScreen().bounds.size.height/2)
                            }, completion: {(finished: Bool) -> Void in
                                self.currentState = .Closed
                                completion?()
                            }
                        )
                    }
                )
            } else {
                contentController?.view.center = CGPointMake(center.x, UIScreen.mainScreen().bounds.size.height/2)
                currentState = .Closed
            }
        }
    }

    public func openMenuFromCenterWithVelocity(velocity: CGFloat) {
        showStatusBar()
        
        let viewCenterY = UIScreen.mainScreen().bounds.size.height/2 + height! - bounceOffset
        currentState = .Displaying
        let duration = Double((viewCenterY - contentController!.view.center.y) / velocity)
        UIView.animateWithDuration(duration, animations: {[unowned self]() -> Void in
            
            if let center = self.contentController?.view.center {
                self.contentController?.view.center = CGPointMake(center.x, viewCenterY)
            }
            
        }, completion: {[unowned self](finished: Bool) -> Void in
            self.currentState = .Shown
        })
