 
 import UIKit
 
+@objc public protocol PagingMenuControllerDelegate: class {
+    optional func willMoveToMenuPage(page: Int)
+    optional func didMoveToMenuPage(page: Int)
+}
+
 public class PagingMenuController: UIViewController, UIScrollViewDelegate {
     
+    public weak var delegate: PagingMenuControllerDelegate?
     private var options: PagingMenuOptions!
     private var menuView: MenuView!
     private var scrollView: UIScrollView!

        menuView.addGestureRecognizer(rightSwipeGesture)
    }
    
    private func currentPagingViewPage() -> Int {
        let pageWidth = self.scrollView.frame.width
        
        return Int(floor((self.scrollView.contentOffset.x - pageWidth / 2) / pageWidth)) + 1
    }
    
    private func targetIndex(#tappedIndex: Int) -> Int {
        switch options.menuDisplayMode {
        case .FlexibleItemWidth(_, let scrollingMode):
            switch scrollingMode {
            case .PagingEnabled:
                return tappedIndex < currentPage ? currentPage-1 : currentPage+1
            default:
                return tappedIndex
            }
        case .FixedItemWidth(_, _, let scrollingMode):
            switch scrollingMode {
            case .PagingEnabled:
                return tappedIndex < currentPage ? currentPage-1 : currentPage+1
            default:
                return tappedIndex
            }
        case .SegmentedControl:
            return tappedIndex
        }
    }
    

        return titles
    }
    
    // MARK: - Gesture handler
    
    private func addSwipeGestureHandlersIfNeeded() {
        switch options.menuDisplayMode {
        case .FlexibleItemWidth(_, let scrollingMode):
