metafizzy / flickity

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

Remove Flickity Slider On certain conditions #1285

Open Asad-ullah-pp opened 9 months ago

Asad-ullah-pp commented 9 months ago

I have used the flickity for product image slider and i want to remove the main slider mages to remove on certain condition. i have used the remove method in another file.

var elem = document.querySelector('.carousel.product__image-slider');
  var flkty = new Flickity(elem, {
    contain: true,
    imagesLoaded: true,
    lazyLoad: 1,
    wrapAround: true,
    pageDots: false,{% if product.images.size < 2 %}
      prevNextButtons : false,{% endif %}adaptiveHeight: true
  });
  console.log("check product main Slider:", flkty);

  var elemThumbnail = document.querySelector('.carousel.product__image-thumbnail');
  var flktyB = new Flickity(elemThumbnail, {
    asNavFor: '.carousel.product__image-slider',
    contain: true,
    imagesLoaded: true,
    lazyLoad: 7,
    pageDots: false,
    prevNextButtons: false
  });

flkty.remove(flkty.cells)