   var scrollSpeedFactor: CGFloat = 1
   var collapseDirectionFactor: CGFloat = 1 // Used to determine the sign of content offset depending of collapse direction
   var previousState: NavigationBarState = .expanded // Used to mark the state before the app goes in background
-  
+
+  private var isTopViewControllerExtendsUnderNavigationBar: Bool {
+    guard let topViewController = topViewController, topViewController.edgesForExtendedLayout.contains(.top) else {
+      return false
+    }
+
+    return topViewController.extendedLayoutIncludesOpaqueBars || navigationBar.isTranslucent
+
+  }
+
   /**
    Start scrolling
 

    frame.origin = CGPoint(x: frame.origin.x, y: frame.origin.y - delta)
    navigationBar.frame = frame

    // Resize the view if the navigation bar is not translucent
    if !navigationBar.isTranslucent {
      let navBarY = navigationBar.frame.origin.y + navigationBar.frame.size.height
      frame = topViewController.view.frame
      frame.origin = CGPoint(x: frame.origin.x, y: navBarY)

    let animations = {
      self.scrollWithDelta(self.fullNavbarHeight, ignoreDelay: true)
      visibleViewController.view.setNeedsLayout()
      if !self.isTopViewControllerExtendsUnderNavigationBar {
        let currentOffset = self.contentOffset
        self.scrollView()?.contentOffset = CGPoint(x: currentOffset.x, y: currentOffset.y + self.navbarHeight)
      }
