Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct fade transition when content modes differ #786

Merged
merged 1 commit into from
May 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Sources/NukeExtensions/ImageViewExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ extension ImageViewController {
)
}

/// Performs cross-dissolve animation alonside transition to a new content
/// Performs cross-dissolve animation alongside transition to a new content
/// mode. This isn't natively supported feature and it requires a second
/// image view. There might be better ways to implement it.
private func runCrossDissolveWithContentMode(imageView: UIImageView, image: ImageContainer, params: ImageLoadingOptions.Transition.Parameters) {
Expand All @@ -410,8 +410,12 @@ extension ImageViewController {
// Create a transition view which mimics current view's contents.
transitionView.image = imageView.image
transitionView.contentMode = imageView.contentMode
imageView.addSubview(transitionView)
transitionView.frame = imageView.bounds
imageView.superview?.insertSubview(transitionView, aboveSubview: imageView)
transitionView.frame = imageView.frame
transitionView.clipsToBounds = imageView.clipsToBounds
transitionView.layer.cornerRadius = imageView.layer.cornerRadius
transitionView.layer.cornerCurve = imageView.layer.cornerCurve
transitionView.layer.maskedCorners = imageView.layer.maskedCorners
Comment on lines +415 to +418
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative to trying to match any masking of imageView is to take a snapshot of the view before it is changed. This branch does that alternative method: main...ejensen:transition-fix-2

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing it!
I don't have any strong preferences in terms of which approach to use. I assume the one from the PR was your primary choice, so I'm OK merging it as is.


// "Manual" cross-fade.
transitionView.alpha = 1
Expand Down
Loading