     var disposeBag = DisposeBag()
     var bookInfo : LocalBookInfo!
     let model = BookModel()
+    
+    var preIndex = 0
 
     @IBAction func doClose() {
         self.dismiss(animated: true, completion: nil)

            
            // 前回読み込んだページ数を取得する.
            let currentIndex = UserDefaults.standard.integer(forKey: UDKey.CurrentPage)
            
            self?.leavesView.reloadData()
            self?.leavesView.currentPageIndex = currentIndex

    override func renderPageAtIndex(index: Int, inContext context: CGContext) {
        // 現在のページ数を保存する.
        if (index > 0) {
            
            if (preIndex < index) {
                print("to right")
                UserDefaults.standard.set(index - 1, forKey: UDKey.CurrentPage)
            } else {
                print("to left")
                UserDefaults.standard.set(index, forKey: UDKey.CurrentPage)
            }
            
            UserDefaults.standard.synchronize()
        }

