Crate web_sys_main_loop

Source
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§

FrameState
Contains the input state for the current frame.
MouseState
Contains the state of the mouse in the current frame

Enums§

MouseButton
The possible buttons that can be pressed on a mouse.

Functions§

start
Runs the closure provided with requestAnimationFrame every possible frame