Use requestAnimationFrame.