mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
18 lines
427 B
JavaScript
18 lines
427 B
JavaScript
//#region src/dom/animation-frame.ts
|
|
/**
|
|
* Request an animation frame with cleanup.
|
|
*
|
|
* @example
|
|
* ```ts
|
|
* const cancel = animationFrame((time) => console.log('Frame at', time));
|
|
* cancel(); // Cancel if needed
|
|
* ```
|
|
*/
|
|
function animationFrame(callback) {
|
|
const id = requestAnimationFrame(callback);
|
|
return () => cancelAnimationFrame(id);
|
|
}
|
|
//#endregion
|
|
export { animationFrame };
|
|
|
|
//# sourceMappingURL=animation-frame.js.map
|