Closed tractanz closed 1 year ago
Sorry, there is no built-in API for destroying all Flickity instances on the page.
One approach would be to use querySelectorAll
let $flickityElems = document.querySelectorAll('.flickity-enabled');
$flickityElems.forEach(($elem) => {
Flickity.data($elem).destroy();
});
Otherwise, you'll need to keep track of the instances you create and then destroy them at the appropriate time
let flickities = [];
let flkty = new Flickity(...);
flickities.push(flkty);
// time to destroy all
flickities.forEach((instance) => instance.destroy());
Hi there,
This is question more than an issue..
I've read through docs here on how to destroy a specific instance of flickity - https://flickity.metafizzy.co/api.html#destroy. I am wondering if there is a way to destroy all flickity instances?
Reason for this is due to my project using Barba.js and my flickity instance is scoped for specific barba views. So I was hoping there is a method I can use to destroy all flickity instances on page leave.