small patch to make the code run in nodejs

Minor tweak to check if window is defined so the animation-timer code can run server side