I'm working on a audio multimedia player (turntable) based on jplayer plugin, and I'm using the rotate property on a div :
setInterval(
开发者_运维知识库 function () {
$('#plateau').animate({
rotate: '+=4deg'
}, 0);
},
3);
Firstly, I would like to stop the rotation when a user clicks on another div.
Secondly, I would like to stop the rotation whith a maximum degree limitation.
Thank you very much.
well for one thing set setInterval equal to a var:
var timer = setInterval(...)
than you can stop it with:
clearInterval(timer)
and then to stop the animation do:
$('#plateau').stop();
Give the timeout a var!
var timer = setTimeout(function(){ ... }, 0);
and when you need to stop it:
clearTimeout( timer );
setInterval
is returning a value. Store it, and then call clearInterval
with this variable as a parameter
toto = setInterval(function(){…})
…
clearInterval(toto)
clearInterval
will stop the regular execution of the function
If it's possible, I search a function who return the actual position in degree of the div, for can sync the movement of the arm with the actual playing position like on a real turntable player :
function rotation_bras(bras_rotation)
{
/*var temps_actuel = $.jPlayer.convertTime(tt);*/ // Send the total time of the track
// Begin position in degree 17deg
// Maximum position in degree 40 deg
// When a track is finish, the arm's turntable comeback at the initial position
// The degree decalage should be depend to the total time of the track
if(bras_rotation==true)
{
BrasTourne = setInterval(function(){$('#bras').animate({rotate: '+=0.1deg'}, 0);});
}
else {
clearInterval(BrasTourne);
$('#bras').stop();
}
}
Thanks again
精彩评论