fix for 'illegal invocation' when animations are off

Was getting an 'Illegal Invocation' error when animations were turned off. Checking if animationFrame is set fixes it.