I'm using the jQuery Rotate plugin, to animate the rotation of an image 90 degrees, and then stop the rotation.
My problem is that it won't stop rotating, even after calling clearInterval();
$(document).ready(function() {
var finalAngle;
var intval = setInterval(function func()
{
$("#myimg").rotate(1);
if(typeof func.angle == 'undefined' )
{
func.angle = 0;
}
func.angle += 1;
finalAngle = func.angle;
}, 1);
if(finalAngle == 90)
{
clearInterval(intval);
}
});
Basically all I'm doing is (statically) counting the angles, and once it hits 90, call the clearInterval function. I had to introduce another variable to store the count so that I could access it outside the setInterval function.