Replaced the setTimout by requestanimationframe.