   
   func hideTabBar() {
     self.tabBarBottom.constant = -self.tabBarHeight.constant
-    UIView.animateWithDuration(self.animationDuration) {
+    UIView.animateWithDuration(self.animationDuration, animations: {
       self.view.layoutIfNeeded()
+    }) { (done) in
+      if done {
+        self.tabBarVisible = false
+      }
     }
   }
   

  }
  
  func calculateTabBarPosition(position: Int) {
    if position <= 0 {
      self.swipeBackCancelled = true
      self.hideTabBarOnCancel()

  weak var destinationVC: UIViewController?
  var previousVC: UIViewController?
  var tabBarVisible = true
  var manualTransition = false
  let animationDuration = 0.3 //duration of show/hide tab bar animation
  let bottomPosition = 0 //bottom tab bar position, 0 - means it will stick to bottom
  @IBOutlet weak var container: UIView!
