Use requestAnimationFrame for repaint