It's generally pretty easy to change the end point of an in-flight animation for a view that's on-screen by repeatedly mutating state:
withAnimation { state = ... }
var body: some View {
...
child
.opacity(state)
}
For a subview that is being removed, using the .transition
modifier we have one chance to setup the endpoint like this:
disappearingChild
.transition(
.modifier(active: EndStateViewModifier(), identity: ...)
)
struct EndStateViewModifier: ViewModifier {
func body(content: Content) -> some View {
content
.opacity(0)
}
}
Is it possible to change the end point mid way through the animation?