mirror of
https://github.com/penpot/penpot.git
synced 2025-07-18 23:57:20 +02:00
♻️ Refactor how rAF/cAF is handled (#6241)
This commit is contained in:
parent
99e64ad387
commit
304c44048f
5 changed files with 45 additions and 28 deletions
28
render-wasm/src/wapi.rs
Normal file
28
render-wasm/src/wapi.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
#[macro_export]
|
||||
macro_rules! request_animation_frame {
|
||||
() => {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
extern "C" {
|
||||
pub fn wapi_requestAnimationFrame() -> i32;
|
||||
}
|
||||
unsafe { wapi_requestAnimationFrame() }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! cancel_animation_frame {
|
||||
($frame_id:expr) => {
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
extern "C" {
|
||||
pub fn wapi_cancelAnimationFrame(frame_id: i32);
|
||||
}
|
||||
unsafe { wapi_cancelAnimationFrame($frame_id) }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub use cancel_animation_frame;
|
||||
pub use request_animation_frame;
|
Loading…
Add table
Add a link
Reference in a new issue