Pause button??
-
HI! Very good slider!
But why is there no pause button? How can I add it?
5 stars slider, you’re doing wonderful job there!
-
I’m sorry, but there’s no way to insert a pause button (except by hard-coding). The only way to pause the slider is by hovering it
Hi, fabiorino!
Sorry for long-long delay.
How can I hard-code it so it won’t go anywhere if I will update the slider(as if the plugin will be updated)?
I’m so much happy with this slider, it’s very nice, but this pause button is a must case for me.Hi, the plugin will be updated, I’m working on it right now!
Paste this wherever you want in your page
<input id=”pause” type=”button” value=”play / pause” />
<script>
var paused = false;
jQuery(document).ready(function($) {
$(‘#pause’).click(function() {
if(paused) {
$(‘ul.cs-slides’).mouseleave();
paused = false;
}
else {
$(‘ul.cs-slides’).mouseenter();
paused = true;
}
});
});
</script>Thanks, Fabiorino. I tried this button, but when I hit it to pause the slider, the slider continue to play if I hover a mouse over it and leave. Is it possible to hardcore it so this will not happen? So when clicked pause the slider will pause 100% even if I hover it with mouse and leave
If you want, I can send you the new version of Crelly Slider that implements some API functions (including play/pause). It’s still in development, and some code may change when I’ll publish the definitive version. At least, for now, you can work on your project.
fabiorino, oh so you will implement this feature in next update, this is great! I can wait for the final version, you are very supportive Fabiorino! Thank you! 🙂
Hi there, I think I found some bug. Examine this code please:
var playing = true; (function($) { $(document).ready(function() { $('#pause').click(function() { $('.crellyslider-slider-myslider').data('crellySlider').pause(); }); $('#resume').click(function() { $('.crellyslider-slider-myslider').data('crellySlider').resume(); }); $('#left').click(function() { if(playing) { $('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); playing = true; } else { $('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); playing = false; } }); }); })(jQuery);What I was trying to achieve: if slider is playing, then the previousSlide works normally. But if the slider is paused, then the previousSlide shows the previous slide and then remain paused(it’s not by default). But this didn’t work out. Instead, this is what happens:
If I push the #pause the slider is stops, but if I press then the #left button the slider change to previous slide and then continue and when the time is passed(of the data-time of the slide) then the whole background turns to transparent.I also tried to do this, but it didn’t worked out:
$('#theleft').click(function() { if(playing) { $('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); playing = true; } else { $('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); $('.crellyslider-slider-myslider').data('crellySlider').pause(); playing = false; } });Any idea of how can I achieve the working pause, resume, left and right buttons, please?
All the rest seems very nice and cool 🙂Hi, that is not a bug but the normal behaviour.
If you want the slider to stay paused, you should try something like this:$('#theleft').click(function() { if(playing) { $('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); playing = true; } else { $('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); setTimeout(function() { $('.crellyslider-slider-myslider').data('crellySlider').pause(); playing = false; }, 4000); // your slides ease in + 1000. In this case, 3000+1000 } });This will work if all your slides have, more or less, an equal ease in time. Basically, the slider can’t be paused while the slide animation is being performed. For that reason I used a setTimeout function to wait about 3000 seconds (I set 3000+1000=4000 to be absolutely sure), the time that the slides take to finish the animation, before pausing the slider again.
*Sorry for the mistake. #theleft and #left are the same.
I don’t know what exactly you mean by “Basically, the slider can’t be paused while the slide animation is being performed”, because I can pause the slider in any period of time, simply by pressing first the resume button I made and then the pause button. It works. Following this logic, I tried also this:
var playing = true; (function($) { $(document).ready(function() { $('#pause').click(function() { $('.crellyslider-slider-myslider').data('crellySlider').pause(); }); $('#resume').click(function() { $('.crellyslider-slider-myslider').data('crellySlider').resume(); }); $('#left').click(function() { if(playing) { $('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); playing = true; } else { $('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); $('.crellyslider-slider-myslider').data('crellySlider').resume(); $('.crellyslider-slider-myslider').data('crellySlider').pause(); playing = false; } }); }); })(jQuery);But it didn’t work out. Basically, I want the logic behavior: if the slider paused and the user pressing left, the slide should change but remain paused.
Also, I want to start the slider paused, but not sure how to do this.
I hope you can help me with this or make it somehow to work in this order, because I really liked this slider.Side note: @invresive Your posts hit the spam queue. They original post is released and the 5 duplicate and test posts have been deleted.
Jan Dembowski, I don’t know why, but I couldn’t post. Tried that for some times and then just registered again. Thanks for taking care about it, hopefully it won’t happen again
PREMISE:
The pause() function can’t be fired right after previousSlide(), you can use pause() only after the slide in animation is completed.
That’s why this$('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); $('.crellyslider-slider-myslider').data('crellySlider').resume(); $('.crellyslider-slider-myslider').data('crellySlider').pause();or this:
$('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); $('.crellyslider-slider-myslider').data('crellySlider').pause();won’t work: you are firing pause() too early. I know that sounds strange, if you want a more technical explanation, please ask me and/or read about how do timers work in Javascript.
SOLUTION:
I made a mistake in my previous post: in that piece of code that I posted before i wrote 4000 milliseconds, but they are way too much. I wanted to write 400. That’s the corrected code:$('#theleft').click(function() { if(playing) { $('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); playing = true; } else { $('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); setTimeout(function() { $('.crellyslider-slider-myslider').data('crellySlider').pause(); playing = false; }, 400); } });Basically, I want the logic behavior: if the slider paused and the user pressing left, the slide should change but remain paused.
I understood, please test the code above.
Also, I want to start the slider paused, but not sure how to do this.
In your slider settings you can add some callbacks.
Overwrite beforeStart : function() {}, with this:beforeStart : function() { setTimeout(function() { jQuery('.crellyslider-slider-myslider').data('crellySlider').pause(); }, 400); },IMPORTANT:
I’ve always wrote 400, I’ve calculated it in this way:
slides Ease In + 100.
The default ease in of the slides is 300, so 400 = 300 + 100Oh… I misunderstood you before.
The code above didn’t work, frankly. But I took the liberty and change it a bit with a sense of previously stated argument about the resume-pause buggy thing. And it worked! Just before the pause(), place the resume() and it will work. Without this, it doesn’t.$('.crellyslider-slider-myslider').data('crellySlider').previousSlide(); setTimeout(function() { $('.crellyslider-slider-myslider').data('crellySlider').resume(); $('.crellyslider-slider-myslider').data('crellySlider').pause(); playing = false; }, 400);I don’t know why there’s a need of resume() before the pause in such case, if you think you know the answer I would be really glad to hear it.
Also, thanks a lot of the beforeStart function, it did help me to start the slider in pause mode
HOTDAMN! I LIKE THIS SLIDER! 😀P.S. just at this moment, I noticed something… If the slider is paused and I use the swipe option, the slider come back to resume it self after the slide is changed. Is there a way to control the swipe function with JS, perhaps? The same thing is with regular navigation buttons(cs-controls and cs-navigation).
I don’t know why there’s a need of resume() before the pause in such case, if you think you know the answer I would be really glad to hear it.
Mmhh, strange I don’t know. Anyway, no big deal. If it works, stick with it xD
If the slider is paused and I use the swipe option, the slider come back to resume it self after the slide is changed. Is there a way to control the swipe function with JS, perhaps?
Try something like this:
jQuery('.crellyslider-slider').on('swipe', function(event) { if(! playing) { setTimeout(function() { jQuery('.crellyslider-slider-myslider').data('crellySlider').resume(); jQuery('.crellyslider-slider-myslider').data('crellySlider').pause(); playing = false; }, 1000); } });Notice the higher timeout (1000ms), because swiping is slower than clicking a button
Oh man, you’re awesome! that worked just perfectly nice!
How can I target rest of the buttons? There’s the left and right(cs controls: cs-next and cs-previous) and there’s the circles(cs-navigation).
The topic ‘Pause button??’ is closed to new replies.