dimanche 6 septembre 2015

I need the "if" statement to keep evaluating (JS)

I've gotta be doing something simple wrong. I'm tracking the speed of the cursor movement. The cursor has been replaced with a 50px x 50px square. If the speed is greater than or equal to 1.00, the cursor square should be red. If it's slower, it should be blue. The problem is, when I load the page the cursor is blue and does not turn red no matter how fast I move it.

setInterval(function () {
    if (speed >= 1.00) {
        $('#cursor').css('background', 'red');
    } else {
        $('#cursor').css('background', 'blue');
    }
}, 20);

Any help is appreciated!

Aucun commentaire:

Enregistrer un commentaire