Internal loop only runs once, containing loop runs endlessly
- by Mark
noob question I'm afraid.
I have a loop that runs and rotates the hand of a clock and an internal loop that checks the angle of the hand if it is 90, 180, 270 and 360. On these 4 angles the corresponding div is displayed and its siblings removed. The hand loops and loops eternally, which is what I want, but the angle check only runs the loop once through the whole 360. As the hand passes through the angles it is correctly displaying and removing divs but is doesn't continue after the first revolution of the clock.
I've obviously messed up somewhere and there is bound to be a more efficient way of doing all this. I am using jQueryRotate.js for my rotations. Thanks for your time.
jQuery(document).ready(function(){
var angle = 0;
setInterval(function(){
jQuery("#hand").rotate(angle);
function movehand(){
if (angle == 90) {
jQuery("#intervention").fadeIn().css("display","block").siblings().css("display","none");
} else if (angle == 180) {
jQuery("#management").fadeIn().css("display","block").siblings().css("display","none");
} else if (angle == 270) {
jQuery("#prevention").fadeIn().css("display","block").siblings().css("display","none");
} else if (angle == 360) {
jQuery("#reaction").fadeIn().css("display","block").siblings().css("display","none");
} else {movehand;}
};
movehand();
angle+=1;
},10);
});