     if page >= 0 && page < images.count {
       var offset = collectionView.contentOffset
       offset.x = CGFloat(page) * collectionView.frame.size.width
+
       collectionView.setContentOffset(offset, animated: animated)
     }
   }
 
   public func next(animated: Bool = true) {
-    page++
-    goTo(page, animated: animated)
+    goTo(page + 1, animated: animated)
   }
 
   public func previous(animated: Bool = true) {
-    page--
-    goTo(page, animated: animated)
+    goTo(page - 1, animated: animated)
   }
 }
 


  public func scrollViewDidScroll(scrollView: UIScrollView) {
    let pageWidth = collectionView.frame.size.width
    page = Int(floor((collectionView.contentOffset.x - pageWidth / 2) / pageWidth) + 1)
  }
}

import UIKit

public protocol LightboxControllerDelegate: class {

  func lightboxControllerDidMoveToPage(controller: LightboxController, page: Int)
}

public class LightboxController: UIViewController {

  var images = [UIImage]()

  public var delegate: LightboxControllerDelegate?

  public private(set) var page = 0 {
    didSet {
      delegate?.lightboxControllerDidMoveToPage(self, page: page)
      println(page)
    }
  }

  public lazy var dataSource: LightboxDataSource = { [unowned self] in
    let dataSource = LightboxDataSource(data: self.images)
