Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6078633
deferUntilFrame.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
618 B
Referenced Files
None
Subscribers
None
deferUntilFrame.js
View Options
// 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
)
{
const
checkFrame
=
()
=>
{
if
(
frameCount
<=
0
)
{
callback
();
}
else
{
frameCount
--
;
requestAnimationFrame
(
checkFrame
);
}
};
checkFrame
();
}
module
.
exports
=
deferUntilFrame
;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 5 2026, 10:14 (6 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a7/eb/41b374db8a8daedd30475adfa0a9
Default Alt Text
deferUntilFrame.js (618 B)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment