fireworks-js
fireworks-js copied to clipboard
feat: adding custom event handler
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
- [x] run
pnpm format - [ ] documentation is changed or added
- [x] commit message and code follows the Developer's Certification of Origin and the Code of conduct