         case .Changed:
             let transform = targetView.transform.a
             targetView.transform = CGAffineTransformMakeScale(scale, scale)
-        case .Ended , .Cancelled :
-            if scale < 1.0 {
-                self.moveImageToCenter()
-            } else {
-            }
+        case .Ended , .Cancelled:
+            let center = targetView.center
+            self.adjustBoundsAndTransform(targetView)
+            self.adjustImageViewFrame()
         default:
             _ = 0
         }
+        self.debug()
     }
     
     func close() {

                self.imageView.frame.size = CGSizeMake(width, height)
                self.imageView.center = self.window.center
                }) { (_) -> Void in
                    self.imageView.bounds.size = self.imageView.frame.size
                    self.imageView.transform = CGAffineTransformMakeScale(1, 1)
            }
        }
    }

        self.moveToFirstFrame { () -> Void in
            self.close()
        }
//        self.debug()
    }
    
    func imageDragged(recognizer:UIPanGestureRecognizer) {
