javascriptjqueryglidejs

How to get the current slide no in Glide.js


Hi how can I get the current slide no when I click next and previous button in GLide.js http://glide.jedrzejchalubek.com/docs.html#intro.

var carousel = $('#Carousel').glide({
                type: 'carousel',
                startAt: 1,
                touchDistance: 2,
          afterInit:function(){console.log("paintSlider")},
          autoplay: 0
              });
console.log(carousel.current());

Solution

  • For some reason, the function carousel.current() is not working.

    You can use the code's callback and events instead. Example:

    var carousel = $('#Carousel').glide({
                type: 'carousel',
                ...
                afterTransition : function(event) {
                    console.log(event.index); // the current slide number
                } 
            });
    

    Also, carousel.index() works too!