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

  lazy var collectionViewLayout: UICollectionViewLayout = {
    let layout = UICollectionViewFlowLayout()
    layout.scrollDirection = .Horizontal
    layout.minimumLineSpacing = 10
    layout.minimumInteritemSpacing = 2
    layout.sectionInset = UIEdgeInsets(top: 10, left: 10, bottom: 10, right: 10)
    return layout
    }()


public class LightboxController: UIViewController {

  var images = [UIImage]()
  var page = 0

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