replaced setInterval with request animation frame

replaced setInterval with request animation frame