using requestAnimationFrame
bug fixed