sycamore::motion

Function create_raf

source
pub fn create_raf(
    cb: impl FnMut() + 'static,
) -> (Signal<bool>, Rc<dyn Fn() + 'static>, Rc<dyn Fn() + 'static>)
Expand description

Schedule a callback to be called on each animation frame. Does nothing if not on wasm32 target.

Returns a tuple of (running, start, stop). The first item is a boolean signal representing whether the raf is currently running. The second item is a function to start the raf. The third item is a function to stop the raf.

The raf is not started by default. Call the start function to initiate the raf.