 
   public func updateImageConstraints() {
     if let image = imageView.image {
+      let viewWidth = bounds.size.width
+      let viewHeight = bounds.size.height
+
       let imageWidth = image.size.width
       let imageHeight = image.size.height
 
-      let viewWidth = bounds.size.width
-      let viewHeight = bounds.size.height
-
-      // Center image if it is smaller than screen
+      // Center image
       var hPadding = (viewWidth - scrollView.zoomScale * imageWidth) / 2
-      if hPadding < 0 { hPadding = 0 }
+      if hPadding < 0 {
+        hPadding = 0
+      }
 
       var vPadding = (viewHeight - scrollView.zoomScale * imageHeight) / 2
-      if vPadding < 0 { vPadding = 0 }
+      if vPadding < 0 {
+        vPadding = 0
+      }
 
       imageConstraintLeading.constant = hPadding
       imageConstraintTrailing.constant = hPadding

extension LightboxView: UIScrollViewDelegate {

  public func scrollViewDidZoom(scrollView: UIScrollView) {
    println("Zoom")
    updateImageConstraints()
  }


      relatedBy: .Equal, toItem: self, attribute: .Bottom,
      multiplier: 1, constant: 0))

    imageConstraintLeading = NSLayoutConstraint(item: imageView, attribute: .Leading,
      relatedBy: .Equal, toItem: scrollView, attribute: .Leading,
      multiplier: 1, constant: 0)
