badger-accordion
badger-accordion copied to clipboard
Unmounting
Hi there! Thanks for creating this awesome, easy-to-use, and accessible accordion component! Extremely handy.
One major issue though that would prevent me from actually using this in a project is the lack of an "unmount" method. Most of the sites I build use a PJAX library such as Barba to create fluid transition animations between pages. In order to avoid memory leaks, I would need some way to "unmount" badger accordion (i.e. remove event listeners) before navigating to a new page. I looked at the documentation and read over the source and I can't seem to find a way to do this.
Please let me know if there is a solution, or if you would consider adding this feature, or perhaps I could take a stab at it and submit a PR.
Thanks!
Hi Mike,
Thanks for getting in touch and your kind words.
I had a PR raised for a similar kind of feature - https://github.com/stuartjnelson/badger-accordion/pull/26 - I haven't merged this in yet.
Would having a setting like this allow you to do what you'd like? I was thinking of calling it disableListenersOnLoad
.
I'm not sure that's what I'm looking for. This is the API I'm picturing:
const accordion = new BadgerAccordion(node)
// Later, before page transition, I could call this method to remove all event listeners (aka unmount)
accordion.unmount()