Page MenuHomeWickedGov Phorge

deferUntilFrame.js
No OneTemporary

Size
596 B
Referenced Files
None
Subscribers
None

deferUntilFrame.js

// Adopted from Vector 2022
/**
* Helper method that calls a specified callback before the browser has
* performed a specified number of repaints.
*
* Uses `requestAnimationFrame` under the hood to determine the next repaint.
*
* @param {Function} callback
* @param {number} frameCount The number of frames to wait before calling the
* specified callback.
*/
function deferUntilFrame( callback, frameCount ) {
if ( frameCount === 0 ) {
callback();
return;
}
requestAnimationFrame( () => {
deferUntilFrame( callback, frameCount - 1 );
} );
}
module.exports = deferUntilFrame;

File Metadata

Mime Type
text/plain
Expires
Oct 5 2026, 10:06 (6 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
8f/3e/88d4c9ad11e22219eaf347230069
Default Alt Text
deferUntilFrame.js (596 B)

Event Timeline