     private func scaleToFillBoundsWithImageRotatedBy(angle: Double) -> CGFloat {
         
         let pi = M_PI
-        let size = bounds.size
+        let containerSize = bounds.size
         
         var theta = fabs(angle - 2 * pi * trunc(angle / pi / 2) - pi)
         if theta > pi / 2 {
             theta = fabs(pi - theta)
         }
         
-        let H = Double(size.height)
-        let W = Double(size.width)
-        let h = Double(size.height)
-        let w = Double(size.width)
+        let H = Double(containerSize.height)
+        let W = Double(containerSize.width)
+        let h = Double(contentSize.height)
+        let w = Double(contentSize.width)
         
         let scale1 = (H * cos(theta) + W * sin(theta)) / h
         let scale2 = (H * sin(theta) + W * cos(theta)) / w

            minScale = maxScale
        }
        
        maximumZoomScale = maxScale
        minimumZoomScale = minScale
        print("min scale = \(minScale), max scale = \(maxScale)")
    }
    
    // MARK: - Rotation support

        debugPrint("enclosingRect after = \(enclosingRect)")
        
        // 4. Транслируем центр полученного прямоугольника в исходную систему координат
        let translateTransform = CGAffineTransformMakeTranslation(sourceCenter.x, sourceCenter.y)
        let rotationTransform = CGAffineTransformMakeRotation(-angle)
        let reverseTransform = CGAffineTransformConcat(
            CGAffineTransformConcat(CGAffineTransformInvert(translateTransform), rotationTransform),
            translateTransform
        )
        
        let targetCenter = CGPointApplyAffineTransform(enclosingRect.center, reverseTransform)
        debugPrint("targetCenter = \(targetCenter)")
        
        // 5. Рассчитываем contentOffset, при котором центром bounds окажется targetCenter
        targetContentOffset.memory = CGPoint(
