fireworks-js icon indicating copy to clipboard operation
fireworks-js copied to clipboard

feat: adding custom event handler

Open sentisso opened this issue 2 years ago • 0 comments

I had a special situation in my project, where I'm using fireworks-js, where I needed to detect whenever a firework explodes. One possible way to achieve this is by pre-calculating when a certain firework will explode, which is kinda difficult and not reliable, because it highly depends on the number of animation frames.

The way I handled it in the update function is kinda unorthodox, since it is being run inside an animation frame, but it's the easiest way to achieve this. I also added an example usage to /examples/basic/.

I created this PR as a draft first, since I'd like to first discuss if it's even a good idea. This is not a breaking change in any way and shouldn't be hard at all to maintain, so I don't think it has any downsides. This also created a base for easily implementing even more custom events in the future.

One todo would maybe be to include the coordinates in the event at what place the firework exploded.

Checklist

sentisso avatar Mar 07 '23 10:03 sentisso