UNPKG

@tempots/dom

Version:

Fully-typed frontend framework alternative to React and Angular

31 lines (30 loc) 1.06 kB
import { Renderable } from '../types/domain'; /** * Handle returned by {@link createRafLoop} to stop the animation loop. * @public */ export interface RafLoopHandle { /** Cancel the loop and stop future callbacks. */ dispose: () => void; } /** * Creates a `requestAnimationFrame` loop that calls `callback` on every frame * with the elapsed time in milliseconds since the previous frame. * * The first frame always receives `dt = 0`. * * @param callback - Called each frame with delta time in milliseconds. * @returns A handle with a `dispose()` method to stop the loop. * @public */ export declare function createRafLoop(callback: (dt: number) => void): RafLoopHandle; /** * A Tempo renderable that runs a `requestAnimationFrame` loop for the * lifetime of the component. The loop is automatically stopped when the * renderable is disposed. * * @param callback - Called each frame with delta time in milliseconds. * @returns A renderable. * @public */ export declare const RafLoop: (callback: (dt: number) => void) => Renderable;