# Bevy Web Utils Helpers for working with Bevy on the web ## Bindings This crate includes `wasm_bindgen` bindings to some JS snippets that help with various web tasks, that can be accessed from the `micro_bevy_web_utils::bindings` module - ` orientation_lock(orientation: String);`: Locks the screen to the given orientation. Accepts values defined in the [Screen Orientation API](https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model/Managing_screen_orientation#preventing_orientation_change). Noop on web platforms that do not support locking orientation - ` orientation_unlock();`: Unlocks the screen orientation. Noop when the orientation is not locked, or on web platforms that do not support locking orientation - ` make_selector_fullscreen(selector: String);`: Take a query selector, and requests fullscreen mode for the first matching element. Noop if the query selector does not match any elements. Calling `make_selector_fullscreen("canvas")` is the common usage - ` toggle_selector_fullscreen(selector: String) -> bool;`: Take a query selector and either request fullscreen mode if the window is not in fullscreen, or close fullscreen mode if the window is fullscreen - ` exit_fullscreen();`: Close fullscreen mode - ` bind_selector_touch_events(selector: String);`: Bind touch events to the element. This is used in combination with the `micro_bevy_web_utils::bevy::emit_touch_events` system to send touch events on touch devices - ` teardown_selector_touch_events(selector: String);`: Remove touch event bindings for a given element - ` take_touch_events() -> String;`: Clears the touch event buffer and returns a serialised JSON array containing all of the events that have been recorded since the last call to `take_touch_events` - ` is_fullscreen() -> bool;`: Returns whether an element has fullscreen mode enabled - ` is_touch_device() -> bool;`: Returns whether the device supports touch input ## Bevy System Touch events will only be intercepted after at least one successful call to `bind_selector_touch_events` To dispatch touch events recorded by this library, you can add the `micro_bevy_web_utils::bevy::emit_touch_events` system. You will then receive intercepted touch events in any other system that uses the `Touches` or `EventReader` resources. Alternatively, you can manually use the `take_touch_events` binding to get all the recorded touch events. They _must_ be handled and/or dispatched after being taken, or they will be lost - there is no double buffering or equivalent