Skip to content

Confetti is not triggering if there is a TextField in the view #20

@abushnaq

Description

@abushnaq

Hi all,

The code below does not trigger the confetti either onAppear or onTap. If I remove the TextField both work fine. Is this a known limitation?

import SwiftUI
import Vortex

struct ContentView: View {    
    @State var answer : String = ""
    var suppliedAnswer : String = "Hello"
    var body: some View {
        VortexViewReader { proxy in
            ZStack {
                VStack
                {
                    Text("What is the capital of the United States?")
                     TextField("Placeholder", text: $answer)
                }
                VortexView(.confetti.makeUniqueCopy()) {
                    Rectangle()
                        .fill(.white)
                        .frame(width: 16, height: 16)
                        .tag("square")
                    
                    Circle()
                        .fill(.white)
                        .frame(width: 16)
                        .tag("circle")
                }.onAppear()
                {
                    let location1 = CGPoint(x: 221.0, y: 627.66)
                    let location2 = CGPoint(x: 233.0, y: 200.66)
     
                    proxy.move(to: location1)
                    proxy.burst()
                    proxy.move(to: location2)
                    proxy.burst()
                }
                .onTapGesture { location in
                    proxy.move(to: location)
                    proxy.burst()
                }
            }
        }
    }
}

#Preview {
    ContentView()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions