SwiftUI, prevent the subview to inherit parent's animation

108 views Asked by At

I've been playing with the NavigationPath for some time. I first figured that when a view is inserted into the path (full code is on this answer), the inserted page doesn't have standard navigation transition animation so, I've decided to force one as;

.navigationDestination(for: Int.self) { i in
    if i == 1 {
        ContentsPageView(presentedNumbers: $presentedNumbers)
            .animation(.easeInOut(duration: 0.3))
            .transition(AnyTransition.asymmetric(
                insertion: .move(edge: .leading),
                removal: .move(edge: .trailing))
             )
     } else {
         ReaderPageView(presentedNumbers: $presentedNumbers)
     } 
}                 

This works great since the navigation transition works perfectly however, it created a new problem; The list items inside the ContentsPageView page started to animate.

So, how can I prevent the animation of the subview of ContentsPageView?

0

There are 0 answers