In this SwiftUI code, why does the matched geometry effect have a weird asymmetry (there is a slight left/right and up/down wavering — the Text does not simply animate in a “straight line” from it source and target configuration.)
import SwiftUI
struct MatchedGeometryExample: View {
@Namespace private var animationNamespace
@State private var isExpanded = false
var body: some View {
VStack {
Spacer()
HStack{
Text("Example Text")
.font(isExpanded ? .largeTitle : .body)
.matchedGeometryEffect(id: "exampleText", in: animationNamespace)
.padding()
.background(.pink)
}
Spacer()
Button("Toggle") {
withAnimation(.easeInOut(duration: 0.5)) {
isExpanded.toggle()
}
}
}
}
}
struct MatchedGeometryExample_Previews: PreviewProvider {
static var previews: some View {
MatchedGeometryExample()
}
}