forked from shadowfacts/Tusker
Fix incorrect large image size during expand/shrink animation in some
cases
This commit is contained in:
parent
8a513186aa
commit
49a437583e
|
@ -182,6 +182,8 @@ class LargeImageViewController: UIViewController, UIScrollViewDelegate, LargeIma
|
|||
return zoomRect
|
||||
}
|
||||
|
||||
// MARK: Interaction
|
||||
|
||||
func animateZoomOut() {
|
||||
UIView.animate(withDuration: 0.3, animations: {
|
||||
self.scrollView.zoomScale = self.scrollView.minimumZoomScale
|
||||
|
|
|
@ -39,11 +39,16 @@ class LargeImageExpandAnimationController: NSObject, UIViewControllerAnimatedTra
|
|||
return
|
||||
}
|
||||
|
||||
let ratio = image.size.width / image.size.height
|
||||
let width = finalVCFrame.width
|
||||
let height = width / ratio
|
||||
let finalFrame = CGRect(x: finalVCFrame.midX - width / 2, y: finalVCFrame.midY - height / 2, width: width, height: height)
|
||||
|
||||
var finalFrameSize = finalVCFrame.inset(by: fromVC.view.safeAreaInsets).size
|
||||
let newWidth = finalFrameSize.width / image.size.width
|
||||
let newHeight = finalFrameSize.height / image.size.height
|
||||
if newHeight < newWidth {
|
||||
finalFrameSize.width = newHeight * image.size.width
|
||||
} else {
|
||||
finalFrameSize.height = newWidth * image.size.height
|
||||
}
|
||||
let finalFrame = CGRect(origin: CGPoint(x: finalVCFrame.midX - finalFrameSize.width / 2, y: finalVCFrame.midY - finalFrameSize.height / 2), size: finalFrameSize)
|
||||
|
||||
let imageView = GIFImageView(frame: sourceInfo.frame)
|
||||
imageView.image = image
|
||||
if let gifData = toVC.animationGifData {
|
||||
|
|
|
@ -33,14 +33,20 @@ class LargeImageShrinkAnimationController: NSObject, UIViewControllerAnimatedTra
|
|||
return
|
||||
}
|
||||
|
||||
let originalVCFrame = fromVC.view.frame
|
||||
|
||||
|
||||
let containerView = transitionContext.containerView
|
||||
let ratio = image.size.width / image.size.height
|
||||
let width = originalVCFrame.width
|
||||
let height = width / ratio
|
||||
let originalFrame = CGRect(x: originalVCFrame.midX - width / 2, y: originalVCFrame.midY - height / 2, width: width, height: height)
|
||||
|
||||
let originalVCFrame = fromVC.view.frame
|
||||
var originalFrameSize = originalVCFrame.inset(by: fromVC.view.safeAreaInsets).size
|
||||
let newWidth = originalFrameSize.width / image.size.width
|
||||
let newHeight = originalFrameSize.height / image.size.height
|
||||
if newHeight < newWidth {
|
||||
originalFrameSize.width = newHeight * image.size.width
|
||||
} else {
|
||||
originalFrameSize.height = newWidth * image.size.height
|
||||
}
|
||||
let originalFrame = CGRect(origin: CGPoint(x: originalVCFrame.midX - originalFrameSize.width / 2, y: originalVCFrame.midY - originalFrameSize.height / 2), size: originalFrameSize)
|
||||
|
||||
let imageView = GIFImageView(frame: originalFrame)
|
||||
imageView.image = image
|
||||
if let gifData = fromVC.animationGifData {
|
||||
|
|
Loading…
Reference in New Issue