Paweł Skaba
Paweł Skaba

Reputation: 681

glide js - change number of steps (slides) after using controls

I'm using a glide JS carousel to show some content as a carousel. Docs of the repository are on the website and github.

My current code is following:

jQuery( window ).load(function() {

  var slidesNumber = null;

  if(document.body.classList.contains('single-portfolio')) {
    slidesNumber = 5;
  } else {
    slidesNumber = 4;
  }

  var glide = new Glide('.glide', {
    type: 'carousel',
    perView: slidesNumber,
    autoplay: 4000,
    animationDuration: 1000,
    focusAt: 1
  })
  
  glide.mount()
});

What I am trying to achieve is to change the default number of steps (slides) when clicked on the next/prev buttons. At the moment it is always ONE slide. While I would like to use my variable (var slidesNumber) to set as the expected behavior.

I've went through the documentation but it says nothing about that.. is it even doable?

Upvotes: 0

Views: 1002

Answers (1)

Fettabachi
Fettabachi

Reputation: 89

The code you've provided works as expected. In my case, 4 slides are displayed because that class isn't present on the body of my document. You may want to log the var to the console and be sure there is more than 1 slide.

Also, providing some html would be helpful.

Upvotes: 1

Related Questions