effects-library icon indicating copy to clipboard operation
effects-library copied to clipboard

Allow to start and stop the effects programmatically

Open DaemonLoki opened this issue 3 years ago • 2 comments

Having the option to manually start and end the effects allows for more use-cases. Right now, this is only possible by manipulating the alpha of the effects which is not ideal in terms of both user- and developer-experience.

The idea is to have a .start() and .stop() functionality for all effects. Although different implementations would be necessary for the SpriteKit and CAEmitterLayer based effects, the API has to be the same for making it a streamlined effort for developers to integrate.

DaemonLoki avatar Jun 21 '22 08:06 DaemonLoki

I was looking to pass a Binding to start/stop the effect. Yes, as you said, it's necessary.

Dave181295 avatar Mar 20 '23 17:03 Dave181295

That's one approach for sure @Dave181295!

So, what you always can do, is to have a @State property that's conditionally showing the respective effect. Something in the realm of:

@State private var showingEffect = true
/// ...
if showingEffect {
    ConfettiView()
}
/// ...
.onAppear {
    DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
        withAnimation {
            showingEffect = false        
        }
    }
}

But that would just be a workaround for now, we'll find a better way and expose that in one of the upcoming versions! If you have wishes for the functionality, feel free to add them here! :)

DaemonLoki avatar Mar 28 '23 12:03 DaemonLoki