79493093

Date: 2025-03-07 17:48:24
Score: 1
Natty:
Report link

I've found a solution here: https://swiftui-lab.com/matchedgeometryeffect-part1/

Basically what's needed is to use this 'invisible' transition:

extension AnyTransition {
    static var invisible: AnyTransition {
        AnyTransition.modifier(
            active: InvisibleModifier(pct: 0),
            identity: InvisibleModifier(pct: 1)
        )
    }
    
    struct InvisibleModifier: AnimatableModifier {
        var pct: Double
        
        var animatableData: Double {
            get { pct }
            set { pct = newValue }
        }
        
        
        func body(content: Content) -> some View {
            content.opacity(pct == 1.0 ? 1 : 0)
        }
    }
}
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Artur Radiuk