Expand description
web-sys-main-loop provides a main loop (or game loop), and input handling, for a web_sys window.
Example:
use web_sys_main_loop::FrameState;
let window = web_sys::window().unwrap();
web_sys_main_loop::start(&window, move |frame_state: FrameState| {
...
// Gets the position (X, Y) of the cursor in the window
// context
let curr_position = frame_state.mouse_state.get_position();
...
});
Structs§
- Frame
State - Contains the input state for the current frame.
- Mouse
State - Contains the state of the mouse in the current frame
Enums§
- Mouse
Button - The possible buttons that can be pressed on a mouse.
Functions§
- start
- Runs the closure provided with requestAnimationFrame every possible frame