I’m attempting to current a modal that accommodates a component utilizing matchedGeometryEffect
. I’ve run into an issue — if I animate the transition, the matchedGeometryEffect
animates as properly. I’d prefer it to not animate the primary time, however solely in response to the consumer’s motion.
Minimal instance:
struct Modal: View {
@Namespace non-public var modalNamespace
var physique: some View {
HStack {
Textual content("Choice 1")
.matchedGeometryEffect(id: "option1", in: modalNamespace)
Textual content("Choice 2")
.matchedGeometryEffect(id: "option2", in: modalNamespace)
}
.body(maxWidth: .infinity)
.background(
Colour.blue
.matchedGeometryEffect(id: "option2", in: modalNamespace, isSource: false)
)
}
}
struct ContentView: View {
@State non-public var showModal: Bool = false
var physique: some View {
ZStack {
Button {
withAnimation {
showModal = true
}
} label: {
Textual content("Present modal")
}
if showModal {
Colour.grey
.onTapGesture {
showModal = false
}
VStack {
Spacer()
Modal()
Spacer()
}
.transition(.transfer(edge: .backside))
}
}
}
}
In the true app, the modal accommodates a segmented management that makes use of matchedGeometryEffect
. I wish to preserve the animation in response to the consumer’s motion, however I actually wish to take away this undesirable animation throughout view’s transition.
Can anybody assist me slide this modal in with out triggering that animation? 🙂