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

Improve cross dissolve transition accuracy #787

Merged
merged 3 commits into from
May 31, 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
14 changes: 11 additions & 3 deletions Sources/NukeExtensions/ImageViewExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -410,12 +410,19 @@ extension ImageViewController {
// Create a transition view which mimics current view's contents.
transitionView.image = imageView.image
transitionView.contentMode = imageView.contentMode
imageView.superview?.insertSubview(transitionView, aboveSubview: imageView)
transitionView.frame = imageView.frame
transitionView.tintColor = imageView.tintColor
transitionView.tintAdjustmentMode = imageView.tintAdjustmentMode
#if swift(>=5.9) // preferredImageDynamicRange was back-ported to all iOS/tvOS versions, but only available when using the iOS/tvOS 17+ SDKs
transitionView.preferredImageDynamicRange = imageView.preferredImageDynamicRange
#endif
transitionView.preferredSymbolConfiguration = imageView.preferredSymbolConfiguration
transitionView.isHidden = imageView.isHidden
transitionView.clipsToBounds = imageView.clipsToBounds
transitionView.layer.cornerRadius = imageView.layer.cornerRadius
transitionView.layer.cornerCurve = imageView.layer.cornerCurve
transitionView.layer.maskedCorners = imageView.layer.maskedCorners
imageView.superview?.insertSubview(transitionView, aboveSubview: imageView)

// "Manual" cross-fade.
transitionView.alpha = 1
Expand All @@ -430,9 +437,10 @@ extension ImageViewController {
transitionView.alpha = 0
imageView.alpha = 1
},
completion: { isCompleted in
if isCompleted {
completion: { [weak transitionView] isCompleted in
if isCompleted, let transitionView {
transitionView.removeFromSuperview()
transitionView.image = nil
}
}
)
Expand Down
Loading