mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
feat(store): initial release (#279)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Request an animation frame and return a cleanup function to cancel it.
|
||||
*
|
||||
* @param callback - The callback to invoke on the next animation frame
|
||||
* @returns A cleanup function that cancels the animation frame request
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const cancel = animationFrame((time) => {
|
||||
* console.log('Frame at', time);
|
||||
* });
|
||||
*
|
||||
* // Later, cancel if needed
|
||||
* cancel();
|
||||
* ```
|
||||
*/
|
||||
export function animationFrame(callback: FrameRequestCallback): () => void {
|
||||
const id = requestAnimationFrame(callback);
|
||||
return () => cancelAnimationFrame(id);
|
||||
}
|
||||
Reference in New Issue
Block a user