adds request animation frame to onclick event