A small collection of functions to help build on the capabilities of the
requestAnimationFrame browser API, enabling you to navigate the browser's repaint cycle a little more easily.
The following functions are exported from this library:
afterFuturePaint(callbackFunction[, numberOfPaints = 1])
Fire a callback after the browser's next paint. This is handy when you need to perform some sort of action only after previous DOM changes have been painted to the DOM. If a second paramter is passed, the callback will fire only after that many paints have taken place.
In the event you need to cancel the callback defined for
cancelAfterFuturePaint to cancel that callback, preventing it from firing.
npm install request-animation-helpers
Fire a Callback After Next Repaint
Fire a Callback After Several Repaints
Cancel a Scheduled Callback
;const id =;// will no longer fire after next repaint!;
To use these helpers an old-school environment, or without the help of a bundler, reference the
RAHelpers object and call the method you desire: