 import UIKit
+
+public protocol LightboxControllerDelegate: class {
+
+  func lightboxControllerDidMoveToPage(controller: LightboxController, page: Int)
+}
 
 public class LightboxController: UIViewController {
 
   var images = [UIImage]()
-  var page = 0
+
+  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)


    view.addSubview(collectionView)
    setupConstraints()
  }

  // MARK: - Autolayout

    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) {
    goTo(page + 1, animated: animated)
  }

  public func previous(animated: Bool = true) {
    goTo(page - 1, animated: animated)
  }
}

