naikus / svg-gauge

Minimalistic, animated SVG gauge. Zero dependencies
MIT License
319 stars 74 forks source link

Feature: Add destroy manage to work with lifecycle hooks #8

Open MartinMuzatko opened 6 years ago

MartinMuzatko commented 6 years ago

Hello! In my app, I'm using svg-gauge and it looks wonderful!. I would like to have a destroy function on the gauge object, to remove the gauge again. This helps to mount/unmount new templates.. Right now I have to remove the gauge container child elements on my own. Maybe there are also some eventlisteners that need to be removed

naikus commented 6 years ago

Hello @MartinMuzatko , can you specifically tell me what you are trying to do? The gauge currently appends to the container its attached. Are you re-creating the gauge and you want to replace the existing gauge? Thanks, Aniket

MartinMuzatko commented 6 years ago

Hello @naikus. Right now, I think I found a workaround to check if the gauge already exists and otherwise update the current one. I know from most components I use like this, that they provide a teardown mechanism, to remove the element and all the event-listeners for convenience. Example: https://flickity.metafizzy.co/api.html#destroy

Your thoughts?