     
     private func updateMasks(animated animated: Bool = false) {
         
+        let maskSize = CGSize(
+            width: bounds.size.width,
+            height: (bounds.size.height - cropSize.height) / 2
+        )
+        
         let animation = {
-            
             self.topMask.frame = CGRect(
-                x: 0,
-                y: 0,
-                width: self.cropView.frame.origin.x + self.cropView.frame.size.width,
-                height: self.cropView.frame.origin.y
+                origin: CGPoint(x: 0, y: self.bounds.top),
+                size: maskSize
             )
-            
             self.bottomMask.frame = CGRect(
-                x: self.cropView.frame.origin.x,
-                y: self.cropView.frame.origin.y + self.cropView.frame.size.height,
-                width: self.frame.size.width - self.cropView.frame.origin.x,
-                height: self.frame.size.height - (self.cropView.frame.origin.y + self.cropView.frame.size.height)
+                origin: CGPoint(x: 0, y: self.bounds.bottom - maskSize.height),
+                size: maskSize
             )
         }
         

        bottomMask.backgroundColor = maskColor
        
        addSubview(scrollView)
        addSubview(cropView)
        addSubview(topMask)
        addSubview(bottomMask)
        

        setImageRotation(0)
        
        // scale the image
        cropSize = CGSize(
            width: bounds.size.width,
            height: bounds.size.width / cropAspectRatio
        )
        
        let scaleX = image.size.width / cropSize.width
        let scaleY = image.size.height / cropSize.height
        let scale = min(scaleX, scaleY)     // get minimum scale to fill canvas with image
        
        let minZoomBounds = CGRect(
            x: 0,
            y: 0,
            width: image.size.width / scale,
            height: image.size.height / scale
        )
        
        originalSize = minZoomBounds.size
        
        scrollView.bounds = minZoomBounds
        scrollView.center = self.center
        scrollView.contentSize = scrollView.bounds.size
        
        scrollView.imageView.frame = scrollView.bounds
        
        originalPoint = convertPoint(scrollView.center, toView: self)
        
        updateMasks()
        
