Max jquery counter

I read countless SO posts and made numerous attempts, but the whole day later I was still stuck.

My code, combined with the jquery plugin that I use, can be seen here in this jsfiddle

What am I trying to do?

For this project, I turn to the iTunes API, which provides me with a list of songs by the named artist. Then I save these mp4a files ( one example ) in an array, and each time an image record is clicked (see Jsfiddle), the next song / item in the array. Each of these fragments is 30 seconds. It works great.

JQuery issues

I use the jquery animation plugin to rotate the recording image for 30 seconds, as this is the length of each song. This works fine with the code below / jsfiddle if I clicked a record once and played only one song. However, if I click on a record to play the next song, 30 seconds will be added for each click. Again, this is not a problem if I wait until the song ends, but if I press, say, three times, all of the sudden 90 seconds will be added to the length of the animation.

Can anyone help so that I can guarantee that the score cannot be greater than 30? I tried all kinds of if / else instructions, but disappointingly I can’t crack it. In addition, I went through the jquery rotate plugin code with a thin dental node and tried to change part of the code there, but also to no avail.

jquery , :

  $(document).ready(function () {
          $('#btn').click(function(){
           $(this).rotate({ count:30, forceJS:true });                  
      });
  });

HTML

<img src="http://www.entertainmentayr.com/joey_Lawrence_files/entertayr%20gold%20record%20LP%20logo%20small%20.png" id="btn">
+4
2

jQuery, .stop( [clearQueue ] [, jumpToEnd ] ), , , rotate. clearQueue true , jumpToEnd . jumpToEnd , , , , , , - , .

$(this).stop(true, true).rotate({ count: 30, forceJS: true });

http://jsfiddle.net/mf6xed3w/1/

+2

, : .stop() . , click . jsFiddle: http://jsfiddle.net/mf6xed3w/2/ , 3 , .

+2

All Articles