     
     open var document: PDFDocument?
     
+    var scrollDirection: UICollectionViewScrollDirection {
+        let flowLayout = collectionViewLayout as! UICollectionViewFlowLayout
+        return flowLayout.scrollDirection
+    }
+    
     private static var flowLayout: UICollectionViewFlowLayout {
         let layout = UICollectionViewFlowLayout()
         layout.scrollDirection = .horizontal

    }
    
    open func indexForPage(_ page: Int) -> Int {
        var currentPage = page - 1
        if currentPage <= 0 {
            currentPage = 0
        }
        if let document = document, currentPage > document.pageCount {
            currentPage = document.pageCount - 1
        }
        return currentPage
    }
    
    open func displayPage(_ page: Int, animated: Bool) {

    }
    
    private func didDisplayPage(_ scrollView: UIScrollView) {
        let page: Int
        switch scrollDirection {
        case .horizontal:
            page = Int((scrollView.contentOffset.x + scrollView.frame.width) / scrollView.frame.width)
        case .vertical:
