MCPcopy Create free account
hub / github.com/GraphiteEditor/Graphite / request_animation_frame

Function request_animation_frame

frontend/wrapper/src/helpers.rs:19–24  ·  view source on GitHub ↗

Helper function for calling JS's `requestAnimationFrame` with the given closure

(f: &Closure<dyn FnMut(f64)>)

Source from the content-addressed store, hash-verified

17use std::time::Duration;
18use wasm_bindgen::JsCast;
19use wasm_bindgen::prelude::*;
20use web_sys::{CanvasRenderingContext2d, HtmlCanvasElement, ImageData, window};
21
22/// Helper function for calling JS's `requestAnimationFrame` with the given closure
23pub(crate) fn request_animation_frame(f: &Closure<dyn FnMut(f64)>) {
24 web_sys::window()
25 .expect("No global `window` exists")
26 .request_animation_frame(f.as_ref().unchecked_ref())
27 .expect("Failed to call `requestAnimationFrame`");

Callers 1

Calls 1

as_refMethod · 0.45

Tested by

no test coverage detected