     collectionView.delegate = self
     collectionView.dataSource = self
     collectionView.register(options.menuItemClass, forCellWithReuseIdentifier: PagingCellReuseIdentifier)
+    collectionViewLayout.registerDecorationViews()
+    configureMenuInteraction()
+    
+    if let state = stateMachine?.state {
+      selectViewController(
+        state.currentPagingItem,
+        direction: .none,
+        animated: false)
+    }
+    
+    if #available(iOS 11.0, *) {
+      pageViewController.scrollView.contentInsetAdjustmentBehavior = .never
+      collectionView.contentInsetAdjustmentBehavior = .never
+    }
+  }
+  
+  open override func viewDidLayoutSubviews() {
+    super.viewDidLayoutSubviews()
+    guard let state = stateMachine?.state else { return }
+    
+    // We need generate the menu items when the view appears for the
+    // first time. Doing it in viewWillAppear does not work as the
+    // safeAreaInsets will not be updated yet.
+    if didLayoutSubviews == false {
+      reloadItems(around: state.currentPagingItem)
+      selectCollectionViewItem(for: state.currentPagingItem)
+      didLayoutSubviews = true
+    }
+  }
+  
+  open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
+    super.viewWillTransition(to: size, with: coordinator)
+    guard let stateMachine = stateMachine else { return }
+    
+    coordinator.animate(alongsideTransition: { context in
+      stateMachine.fire(.transitionSize)
+      let pagingItem = stateMachine.state.currentPagingItem
+      self.reloadItems(around: pagingItem)
+      self.selectCollectionViewItem(for: pagingItem)
+    }, completion: nil)
+  }
+  
+  // MARK: Private
+  
+  fileprivate func configureMenuInteraction() {
+    collectionView.isScrollEnabled = false
+    collectionView.alwaysBounceHorizontal = false
+    
+    if let swipeGestureRecognizerLeft = swipeGestureRecognizerLeft {
+      collectionView.removeGestureRecognizer(swipeGestureRecognizerLeft)
+    }
+    
+    if let swipeGestureRecognizerRight = swipeGestureRecognizerRight {
+      collectionView.removeGestureRecognizer(swipeGestureRecognizerRight)
+    }
     
     switch (options.menuInteraction) {
     case .scrolling:

    case .none:
      break
    }
    collectionViewLayout.registerDecorationViews()
    
    if let state = stateMachine?.state {
      selectViewController(
        state.currentPagingItem,
        direction: .none,
        animated: false)
    }
    
    if #available(iOS 11.0, *) {
      pageViewController.scrollView.contentInsetAdjustmentBehavior = .never
      collectionView.contentInsetAdjustmentBehavior = .never
    }
  }
  
  open override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    guard let state = stateMachine?.state else { return }
    
    // We need generate the menu items when the view appears for the
    // first time. Doing it in viewWillAppear does not work as the
    // safeAreaInsets will not be updated yet.
    if didLayoutSubviews == false {
      reloadItems(around: state.currentPagingItem)
      selectCollectionViewItem(for: state.currentPagingItem)
      didLayoutSubviews = true
    }
  }
  
  open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)
    guard let stateMachine = stateMachine else { return }
    
    coordinator.animate(alongsideTransition: { context in
      stateMachine.fire(.transitionSize)
      let pagingItem = stateMachine.state.currentPagingItem
      self.reloadItems(around: pagingItem)
      self.selectCollectionViewItem(for: pagingItem)
    }, completion: nil)
  }
  
  // MARK: Private
  
  fileprivate func setupGestureRecognizers() {
    let recognizerLeft = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipeGestureRecognizer))
    recognizerLeft.direction = .left
    
    let recognizerRight = UISwipeGestureRecognizer(target: self, action: #selector(handleSwipeGestureRecognizer))
    recognizerRight.direction = .right
    
    collectionView.addGestureRecognizer(recognizerLeft)
    collectionView.addGestureRecognizer(recognizerRight)
  }
  
  @objc fileprivate dynamic func handleSwipeGestureRecognizer(_ recognizer: UISwipeGestureRecognizer) {

  /// _Default: .scrolling_
  open var menuInteraction: PagingMenuInteraction {
    get { return options.menuInteraction }
    set {
      options.menuInteraction = newValue
      configureMenuInteraction()
    }
  }

  /// Determine how the selected menu item should be aligned when it
