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

.opacity transition not working #61

Open
jeanbaptistebeau opened this issue Nov 18, 2022 · 2 comments
Open

.opacity transition not working #61

jeanbaptistebeau opened this issue Nov 18, 2022 · 2 comments

Comments

@jeanbaptistebeau
Copy link

I followed the doc Animating Routes and tried to replace the transition with .opacity, but it doesn't work. When using .move(edge: .bottom).combined(with: .opacity), only the move transition is executed.

@jeanbaptistebeau
Copy link
Author

That could actually be a general bug in SwiftUI, according to this SO answer. I'm currently investigating this.

@frzi
Copy link
Owner

frzi commented Nov 21, 2022

Opacity transition (which should be default) has always been finicky. IIRC it only works if the .animation is applied directly to a top-level view which is rendered conditionally.
I.e.:

Group {
	if showText {
		Text("Hello world")
			.animation(.linear)
	}
}

This is most likely due to Route views always being rendered. It's only the content (the child views) which are rendered conditionally. Or something along those lines 😛

Fair warning: the Animating Routes documentation no longer works as expected since iOS 16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants