Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
71
rated 0 times [  78] [ 7]  / answers: 1 / hits: 19741  / 11 Years ago, wed, june 26, 2013, 12:00:00

  1. I am trying to bind the slider.pause() and slider.play() events to my buttons (see code below).

  2. It works unless I click the play button twice or I click the play button while the slider is running.

  3. Then it seems to run another instance (or something) as it runs at twice the speed and the pause button no longer stops slider



Question: Is there a way to test whether the slider is running before calling slider.play() or are the pause() and/or play() calls in the wrong place?



Please advise.



$(document).ready(function(){
$('.flexslider').flexslider({
animation: fade,
slideshowSpeed: 2000,
pauseOnHover: false,
touch: true,
controlsContainer: .fs-container,
controlNav: true,
manualControls: .flex-control-nav li,
start: function(slider) {
$('.icon-pause').click(function(){
slider.pause();
});

$('.icon-play').click(function(){
slider.play();
});
}
});
});

More From » jquery

 Answers
63

7 months old question, but yea the start property on flexslider fires every time an animation starts.



So the code you have above is binding rebinding the click event.



Instead you want something like:



        $('.icon-pause').click(function(){
$('#your_slider_id').pause();
});


And you'd put this in your page init functions -- or anywhere, just not inside the flexslider initialization.



(Of course .play() is also a method.)


[#77413] Monday, June 24, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ishmaelw

Total Points: 528
Total Questions: 96
Total Answers: 103

Location: Venezuela
Member since Sat, Apr 24, 2021
3 Years ago
;