Improve gallery dismiss transition when source view is relatively small compared to content
See #520
This commit is contained in:
parent
a99fb7f0b0
commit
a442197adf
|
@ -47,8 +47,6 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans
|
||||||
container.addSubview(to.view)
|
container.addSubview(to.view)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This trick does not work as well here as it does for presentation, seemingly
|
|
||||||
// because the delayFactor:0.9 still results in the snapshot fading out too quickly :/
|
|
||||||
let sourceSnapshot = sourceView.snapshotView(afterScreenUpdates: false)
|
let sourceSnapshot = sourceView.snapshotView(afterScreenUpdates: false)
|
||||||
if let sourceSnapshot {
|
if let sourceSnapshot {
|
||||||
let snapshotContainer = sourceView.ancestorForInsertingSnapshot
|
let snapshotContainer = sourceView.ancestorForInsertingSnapshot
|
||||||
|
@ -160,16 +158,21 @@ class GalleryDismissAnimationController: NSObject, UIViewControllerAnimatedTrans
|
||||||
|
|
||||||
contentContainer.frame = sourceFrameInContainer
|
contentContainer.frame = sourceFrameInContainer
|
||||||
content.view.frame = sourceSizeWithDestAspectRatioCenteredInContentContainer
|
content.view.frame = sourceSizeWithDestAspectRatioCenteredInContentContainer
|
||||||
content.view.layer.opacity = 0
|
|
||||||
|
|
||||||
itemViewController.setControlsVisible(false, animated: false, dueToUserInteraction: false)
|
itemViewController.setControlsVisible(false, animated: false, dueToUserInteraction: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delay fading out the content because if it's still big while it's semi-transparent,
|
||||||
|
// seeing the stuff behind it looks odd.
|
||||||
|
animator.addAnimations({
|
||||||
|
content.view.layer.opacity = 0
|
||||||
|
}, delayFactor: 0.35)
|
||||||
|
|
||||||
if let sourceSnapshot {
|
if let sourceSnapshot {
|
||||||
animator.addAnimations({
|
animator.addAnimations({
|
||||||
self.sourceView.layer.opacity = 1
|
self.sourceView.layer.opacity = 1
|
||||||
sourceSnapshot.layer.opacity = 0
|
sourceSnapshot.layer.opacity = 0
|
||||||
}, delayFactor: 0.9)
|
}, delayFactor: 0.5)
|
||||||
}
|
}
|
||||||
|
|
||||||
animator.addCompletion { _ in
|
animator.addCompletion { _ in
|
||||||
|
|
Loading…
Reference in New Issue