-
-
Notifications
You must be signed in to change notification settings - Fork 95
fix: smooth tab switching with fade animations (#1479) #1480
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -117,12 +117,14 @@ final class WebViewController: UIViewController { | |
| topSafeAreaConstraint = view.safeAreaLayoutGuide.topAnchor.constraint(equalTo: webView.topAnchor) | ||
| topSafeAreaConstraint?.isActive = true | ||
| layoutCancellable = layoutSubject | ||
| .debounce(for: .seconds(0.15), scheduler: RunLoop.main) | ||
| .debounce(for: .seconds(0.05), scheduler: RunLoop.main) | ||
| .sink { [weak self] _ in | ||
| guard let view = self?.view, | ||
| let webView = self?.webView, | ||
| view.subviews.contains(webView) else { return } | ||
| webView.alpha = 1 | ||
| UIView.animate(withDuration: 0.2) { | ||
| webView.alpha = 1 | ||
| } | ||
|
Comment on lines
123
to
+127
|
||
| guard self?.topSafeAreaConstraint?.isActive == true else { return } | ||
| self?.topSafeAreaConstraint?.isActive = false | ||
| self?.view.topAnchor.constraint(equalTo: webView.topAnchor).isActive = true | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
.transition(.opacity)is unlikely to apply when switching between different.tab(tabID)values because this branch stays active andCompactViewis updated rather than inserted/removed. To actually crossfade between tabs, giveCompactViewa changing identity at this level (e.g.,.id(tabID)) or apply the transition to the view whose identity changes so SwiftUI performs a removal/insertion animation.