Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to set position in onAppear() #13

Open
BeBeBerr opened this issue Mar 21, 2024 · 0 comments
Open

Unable to set position in onAppear() #13

BeBeBerr opened this issue Mar 21, 2024 · 0 comments

Comments

@BeBeBerr
Copy link

Hi, thanks for the great library.

I found when calling the proxy.move function in onAppear, it doesn't correctly set the position. My code is like this:

struct ConfettiView: View {
    var body: some View {
        VortexViewReader { proxy in
            ZStack {
                Text("Tap anywhere to create confetti.")

                VortexView(.confetti.makeUniqueCopy()) {
                    Rectangle()
                        .fill(.white)
                        .frame(width: 16, height: 16)
                        .tag("square")

                    Circle()
                        .fill(.white)
                        .frame(width: 16)
                        .tag("circle")
                }
                .onTapGesture { location in
                    proxy.move(to: location) // works fine
                    proxy.burst()
                }
                .onAppear {
                    proxy.move(to: CGPoint(x: 0, y: 0)) // doesn't work
                    proxy.burst()
                }
            }
        }
        .navigationSubtitle("Demonstrates on-demand particle bursting")
        .ignoresSafeArea(edges: .top)
    }
}

I think the reason is that the nearestVortexSystem has not been set during onAppear.

What I want is to set an initial position for burst. Is there any workaround? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant