1

I was trying to do a simple navigation between two views programmatically using NavigationLink, but I'd like the navigation transition to fade as opposed to sliding in from the right. I do this with these modifiers around the NavigationView:

NavigationView {
// welcome screen UI code
}
.navigationViewStyle(.stack)
.navigationTransition(.fade(.out).animation(.easeInOut(duration: 0.9)))

For some reason, after the navigation occurs, the pulsing animation jumps. Here's a 5 second video showing the jump.

Forgive my extremely crappy code (this is just a prototype), but here's the code of the SwiftUI view that animates the dot using scaleEffect.

Any ideas why this is happening? Is there some better way to start the animation so it doesn't lag?

The strange thing is that when I transition from the start screen to the dot screen without a navigation, there is no jump. Why does it only jump when I navigate?

if appViewModel.state == .newUser {
   StartScreenView(appViewModel: appViewModel).transition(.opacity.animation(.easeInOut(duration: 1.0)))
else {
   RecordingView().transition(.opacity.animation(.easeInOut(duration: 1.0)))
}
Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
drainmond
  • 11
  • 3
  • Hi @drainmond and welcome to StackOverflow. Please add a a [mcve] to make it easy for people to recreate your problem. Just add the minimal code that can be run to demonstrate the problem. – Ashley Mills Feb 21 '23 at 10:27
  • try using .animation(.spring(), value: buttonScale) on the highest view in the hierarchy instead of withAnimation – Isaac Feb 21 '23 at 17:31

0 Answers0