diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift index 7cb40574d4..c15fc4ea00 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift @@ -43,9 +43,10 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans let appliedSourceToDestTransform: Bool if destFrameInContainer.width > 0 && destFrameInContainer.height > 0 { appliedSourceToDestTransform = true + let scale = min(destFrameInContainer.width / sourceFrameInContainer.width, destFrameInContainer.height / sourceFrameInContainer.height) let sourceToDestTransform = origSourceTransform .translatedBy(x: destFrameInContainer.midX - sourceFrameInContainer.midX, y: destFrameInContainer.midY - sourceFrameInContainer.midY) - .scaledBy(x: destFrameInContainer.width / sourceFrameInContainer.width, y: destFrameInContainer.height / sourceFrameInContainer.height) + .scaledBy(x: scale, y: scale) sourceView.transform = sourceToDestTransform } else { appliedSourceToDestTransform = false diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift index 29dd514388..f844a33a20 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift @@ -49,9 +49,11 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated let origSourceTransform = sourceView.transform let sourceToDestTransform: CGAffineTransform? if destFrameInContainer.width > 0 && destFrameInContainer.height > 0 { + // Scale evenly in both dimensions, to prevent the source view appearing to stretch/distort during the animation. + let scale = min(destFrameInContainer.width / sourceFrameInContainer.width, destFrameInContainer.height / sourceFrameInContainer.height) sourceToDestTransform = origSourceTransform .translatedBy(x: destFrameInContainer.midX - sourceFrameInContainer.midX, y: destFrameInContainer.midY - sourceFrameInContainer.midY) - .scaledBy(x: destFrameInContainer.width / sourceFrameInContainer.width, y: destFrameInContainer.height / sourceFrameInContainer.height) + .scaledBy(x: scale, y: scale) } else { sourceToDestTransform = nil } diff --git a/Tusker/Screens/Gallery/ImageGalleryContentViewController.swift b/Tusker/Screens/Gallery/ImageGalleryContentViewController.swift index a872115378..e723d10246 100644 --- a/Tusker/Screens/Gallery/ImageGalleryContentViewController.swift +++ b/Tusker/Screens/Gallery/ImageGalleryContentViewController.swift @@ -57,7 +57,7 @@ class ImageGalleryContentViewController: UIViewController, GalleryContentViewCon imageView = GIFImageView(image: maybeGrayscaleImage) imageView.translatesAutoresizingMaskIntoConstraints = false - imageView.contentMode = .scaleAspectFit + imageView.contentMode = .scaleAspectFill imageView.isUserInteractionEnabled = true view.addSubview(imageView) NSLayoutConstraint.activate([