Fixed window-resize bug so the animation doesn't glitch on resize