metafizzy / flickity

:leaves: Touch, responsive, flickable carousels
https://flickity.metafizzy.co
7.52k stars 605 forks source link

Activate or Init method? (Improvement / request) #891

Closed clarknelson closed 5 years ago

clarknelson commented 5 years ago

I am creating a website that requires a gallery at desktop screen widths, but has them stacked up on mobile screens. There is a .destroy() method which seems useful in my situation:

var flickity = new Flickity(this, { ... });

$(window).resize(function(){
  if(window.innerWidth < 800){
    flickity.destroy()
  } else {
    // what do I write here? it works when you recreate it like this
    flickity = new Flickity(this, { ... });

    // by the flickity object is already created, maybe there should be a function like this
    flickity.init();
    flickity.create();
  }
});

These are just my thoughts on this topic, would love to know what others think, if this is desired.

desandro commented 5 years ago

Sounds like you should try watchCSS

You can enable and disable Flickity with CSS.

clarknelson commented 5 years ago

oh great, thank you!