diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift index ab985eb29..b26ad4b54 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryDismissAnimationController.swift @@ -84,46 +84,11 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans let content = itemViewController.takeContent() content.view.translatesAutoresizingMaskIntoConstraints = true - content.view.layer.masksToBounds = true content.view.transform = .identity content.view.layer.opacity = 1 content.view.frame = contentContainer.bounds contentContainer.addSubview(content.view) - - let sourceAspectRatio: CGFloat = if sourceFrameInContainer.height > 0 { - sourceFrameInContainer.width / sourceFrameInContainer.height - } else { - 0 - } - let destAspectRatio: CGFloat = if destFrameInContainer.height > 0 { - destFrameInContainer.width / destFrameInContainer.height - } else { - 0 - } - let sourceSizeWithDestAspectRatioCenteredInContentContainer: CGRect - if 0.001 < abs(sourceAspectRatio - destAspectRatio) { - // asepct ratios are effectively equal - sourceSizeWithDestAspectRatioCenteredInContentContainer = CGRect(origin: .zero, size: sourceFrameInContainer.size) - } else if sourceAspectRatio < destAspectRatio { - // source aspect ratio is narrow/taller than dest - let width = sourceFrameInContainer.height * destAspectRatio - sourceSizeWithDestAspectRatioCenteredInContentContainer = CGRect( - x: -(width - sourceFrameInContainer.width) / 2, - y: 0, - width: width, - height: sourceFrameInContainer.height - ) - } else { - // source aspect ratio is wider/shorter than dest - let height = sourceFrameInContainer.width / destAspectRatio - sourceSizeWithDestAspectRatioCenteredInContentContainer = CGRect( - x: 0, - y: -(height - sourceFrameInContainer.height) / 2, - width: sourceFrameInContainer.width, - height: height - ) - } - + container.layoutIfNeeded() let duration = self.transitionDuration(using: transitionContext) @@ -157,7 +122,8 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans } contentContainer.frame = sourceFrameInContainer - content.view.frame = sourceSizeWithDestAspectRatioCenteredInContentContainer + // Using sourceSizeWithDestAspectRatioCenteredInContentContainer does not seem to be necessary here. + // I guess autoresizing takes care of it? itemViewController.setControlsVisible(false, animated: false, dueToUserInteraction: false) } diff --git a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift index 3f33b3bc6..8b7143e1d 100644 --- a/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift +++ b/Packages/GalleryVC/Sources/GalleryVC/GalleryPresentationAnimationController.swift @@ -31,7 +31,7 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated } // Try to effectively "fade out" anything that's on top of the source view. - // The 0.05 duration makes this happen faster than the rest of the animation, + // The 0.1 duration makes this happen faster than the rest of the animation, // and so less noticeable. let sourceSnapshot = sourceView.snapshotView(afterScreenUpdates: false) if let sourceSnapshot { @@ -41,11 +41,8 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated sourceSnapshot.frame = sourceFrameInShapshotContainer sourceSnapshot.transform = sourceView.transform sourceSnapshot.layer.opacity = 0 - UIView.animate(withDuration: 0.05) { + UIView.animate(withDuration: 0.1) { sourceSnapshot.layer.opacity = 1 - // Also fade out the actual source view underneath the snapshot to try - // and account for semi-transparent images. - self.sourceView.layer.opacity = 0 } }