I can specify a different transition for when the view is inserted vs removed:
.transition(
.asymmetric(
insertion: .move(edge: .leading)
removal: .move(edge: .trailing)
)
)
This works fine. However I would like it so ease in quickly, when it is added, and ease out slowly when removed. The following does not appear to do anything, despite compiling just fine.
.transition(
.asymmetric(
insertion: .move(edge: .leading)
.animation(.easeIn(duration: 2)),
removal: .move(edge: .trailing)
.animation(.easeOut(duration: 5))
)
)
Am I misunderstanding the use of .animation as a modifier on transitions?
Demo code:
struct TestView: View {
@State private var showDetails = false
var body: some View {
VStack {
Button("Press to show details") {
withAnimation {
showDetails.toggle()
}
}
if showDetails {
Text("Details go here.")
.background(Color.blue)
.transition(
.asymmetric(
insertion: .move(edge: .leading)
.animation(.easeIn(duration: 5)),
removal: .move(edge: .trailing)
.animation(.easeOut(duration: 5))
)
)
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
