Compare commits

..

2 Commits

Author SHA1 Message Date
Shadowfacts 83d4af2303
Fix interactive gallery dismiss going wrong direction when gesture starts out very slow 2021-09-21 23:46:22 -04:00
Shadowfacts 7c5076d01a
Fix dismissing gallery presented by modally-presented VC removing the
gallery's presenting VC from the view hierarchy

Closes #132
2021-09-21 23:30:38 -04:00
2 changed files with 11 additions and 1 deletions

View File

@ -29,7 +29,8 @@ class LargeImageInteractionController: UIPercentDrivenInteractiveTransition {
var progress = translation.y / 200
if let direction = direction {
progress *= direction
} else {
} else if abs(progress) > 0.01 {
// if the progress is less than +/- 1%, don't set the direction because the translation may be random jitter in the user's finger
direction = progress > 0 ? 1 : -1
progress = abs(progress)
}

View File

@ -68,6 +68,12 @@ class LargeImageShrinkAnimationController: NSObject, UIViewControllerAnimatedTra
blackView.backgroundColor = .black
blackView.alpha = 1
// Save the old superview of toVC so we can move it back after the animation.
// It would be better to just not move toVC and instead remove from fromVC from the
// containerView so that toVC is visible behind it, but that doens't work for some reason
// (the entire screen just goes black, not even the contents of the containerView appear).
let oldSuperview = toVC.view.superview
containerView.addSubview(toVC.view)
containerView.addSubview(blackView)
containerView.addSubview(imageView)
@ -88,6 +94,9 @@ class LargeImageShrinkAnimationController: NSObject, UIViewControllerAnimatedTra
sourceView.alpha = 1
transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
// move the toVC back to the view that it was in before
oldSuperview?.addSubview(toVC.view)
})
}