 
 extension PageMenuController: UIScrollViewDelegate {
     @objc
-    open func scrollViewDidScroll(_ scrollView: UIScrollView) {
-        guard let tb = tabBar else {
-            return
-        }
-        
-        guard tb.isAnimating else {
-            return
-        }
-        
-//        guard let selected = tb.selected else {
-//            return
-//        }
-        
-//        let x = (scrollView.contentOffset.x - scrollView.width) / scrollView.contentSize.width * scrollView.width
-//        tb.line.center.x = selected.center.x + x
-    }
-    
-    @objc
-    open func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
-        previousContentOffset = scrollView.contentOffset.x
-    }
-    
-    @objc
     open func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
         let n = viewControllers.count
         let x = scrollView.contentOffset.x
-        let p = previousContentOffset == x ? 0 : previousContentOffset < x ? 1 : -1
-        
-        guard 0 != p else {
-            return
-        }
-        
-        let i = selectedIndex + p
-        
-        guard selectedIndex != i else {
-            return
-        }
-        
-        guard 0 <= i && i < n else {
-            return
-        }
-        
-        selectedIndex = i
+        let w = scrollView.width
+        let p = Int(floor((scrollView.contentOffset.x - w / 2) / w) + 1)
+        print(selectedIndex, p)
+        
+        selectedIndex = p
         
         removeViewControllers()
         prepareViewControllers()

        viewControllers = []
        super.init(coder: aDecoder)
    }
    
    /**
     An initializer that accepts an Array of UIViewControllers.

        }
    }
    
    /**
     An initializer that initializes the object with a NSCoder object.
     - Parameter aDecoder: A NSCoder instance.
