Glide: Get the current slide

Created on 25 Sep 2018  路  4Comments  路  Source: glidejs/glide

Hi

I'm trying to achieve something like this codepen example.
But with the new Glide version there is no way to get the current slide.

How can i get this to work?

Most helpful comment

You can access current index numer with index property on specific glide instance.

var glide = new Glide('.glide');

console.log(glide.index);

All 4 comments

afterTransition: function (event) {
        coverflow(event.index, event.current);
      console.log(event.index);
console.log(event.current);
    }

full code would look like:

function coverflow(i, el) {
    el.removeClass('pre following')
        .nextAll()
            .removeClass('pre following')
            .addClass('following')
        .end()
        .prevAll()
            .removeClass('pre following')
            .addClass('pre');
}

$('#Glide').glide({
    type: 'slider',
    startAt: 3,
    animationDuration: 500,
    paddings: '25%',
    afterInit: function (event) {
        coverflow(event.index, event.current);
    },
    afterTransition: function (event) {
        coverflow(event.index, event.current);
      console.log(event.index);
    }
});

afterInit and afterTransition does not work with glide v3.2.3

For me (version 3.2.3), this works:

let cookbook = new Glide('.glide');
cookbook.on('move', function(e,f) {
    console.log(cookbook.index);
});
cookbook.mount();

You can access current index numer with index property on specific glide instance.

var glide = new Glide('.glide');

console.log(glide.index);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

thasmo picture thasmo  路  4Comments

LostCrew picture LostCrew  路  3Comments

heliomsolivas picture heliomsolivas  路  8Comments

dkindnes picture dkindnes  路  5Comments

philmarc picture philmarc  路  3Comments