         buttonsScrollView.selectionIndicator.frame = frame
     }
     
+    func scrollButtonsViewToCurrentIndex() {
+        let targetRect = buttonsScrollView.calButtonFrame(currentIdx)
+        buttonsScrollView.scrollRectToVisible(targetRect, animated: true)
+    }
+    
     // MARK: - Buttons
     public func selectionButtonTapped(btn: UIButton) {
         let idx = btn.tag
+        /// set the target index for scrolling buttons view purpose
+        targetIndex = idx
+        
         guard let vcs = viewControllers where idx >= 0 && idx < vcs.count else {
             return
         }

        buttonsScrollView.buttons.forEach { $0.selected = false }
        buttonsScrollView.buttons[currentIdx].selected = true
        
        /// scroll the scroll view if needed
        dispatch_async(dispatch_get_main_queue()) { [weak self] in
            guard let bself = self else { return }
            let targetRect = bself.buttonsScrollView.calButtonFrame(bself.currentIdx)
            bself.buttonsScrollView.scrollRectToVisible(targetRect, animated: true)
        }
        
        NSNotificationCenter.defaultCenter().postNotificationName(LXPageViewWithButtonsViewControllerCurrentViewControllerDidChangeNotification , object: self)
    }
    
    public var viewControllers : [UIViewController]? {

    public let buttonsScrollView: LXButtonsScrollView = LXButtonsScrollView()
    /// data source required by UIpageViewController
    let pageViewControllerDataSource = LXPageViewWithButtonsViewControllerDataSource()
    
    /// page index
    var targetIndex: Int?
    var currentIdx = 0 {
        didSet {
            currentIdxUpdated()
