1

I have a lightbox with a glide slider in it. Glide.js is already initiated. I want on clicking my specified element to re-start the slider. When closing the lightbox I'd like to pause the slider. I can see that this is possible with the API but cant get it to work...

My slider setup

var slider_alt=$("#glide--alt").glide({
    type:"slideshow",
    autoplay:2500, 
    animationDuration:2000,
    hoverpause:false
}),
slider_api=slider_alt.data("glide_api");

My jQuery for trying to restart the slider

popUp_openButton.click(function(){
    slider_alt.jump(1);
    slider_alt.play();
});

popUp_closeButton.click(function(){ 
    slider_alt.pause();
}); 

2 Answers 2

1

Use .refresh():

popUp_closeButton.click(function(){ 
   slider_alt.refresh();
});
2
  • @Anders it should be .refresh(); instead of : Right ?
    – Sree
    Nov 13, 2015 at 0:13
  • Big thanks @Anders & Sree. I managed to get it working on problem. Using the variable slider_alt didnt work... Nov 17, 2015 at 10:40
1

Heres my final working code. On opening the modal window the slider is recalculated and starts at slide 1. On closing its stops clearing all objects and bindings.

//Setting up slider
var slider_alt=$("#glide--alt").glide({
    type:"slideshow",
    autoplay:2500, 
    animationDuration:2000,
    hoverpause:false
}),
slider_alt_api=slider_alt.data("glide_api");


var popUp_openButton    = $('.popUp__button--open'),
popUp_closeButton   = $('.popUp__button--close');

popUp_openButton.click(function(){
    slider_alt_api.refresh();
    slider_alt_api.jump('=1');
});

popUp_closeButton.click(function(){ 
    slider_alt_api.destroy();
});     

$(document).keyup(function(e){
    if(e.keyCode === 27) {
        slider_alt_api.destroy();
    }  
}); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.