Got request animation frame to work correctly.