Skip to main content

UseEuvLayout

Struct UseEuvLayout 

Source
pub struct UseEuvLayout;
Expand description

Layout functionality for managing viewport resize, drawer toggle, and safe area.

Provides methods for tracking mobile viewport, toggling navigation drawer, and handling safe area insets on mobile devices.

Implementations§

Source§

impl UseEuvLayout

Implementation of layout functionality.

Provides methods for managing viewport resize, drawer toggle, and safe area.

Source

pub fn use_resize() -> Signal<bool>

Creates a reactive signal that tracks whether the viewport is in mobile mode and subscribes to browser resize events to keep it updated.

The resize handler is debounced by RESIZE_DEBOUNCE_MILLIS (16ms) to avoid excessive recomputation during continuous resize operations. The listener is automatically removed when the hook context is cleared.

§Returns
  • Signal<bool> - A reactive signal that is true when the viewport is mobile-sized.
Source

pub fn use_drawer_toggle(drawer_open: Signal<bool>) -> Option<Rc<dyn Fn(Event)>>

Creates a click event handler that toggles the mobile nav drawer signal with proper browser history management.

When toggling from open to closed, calls overlay_back to remove the extra history entry that was pushed when the drawer opened. When toggling from closed to open, the use_overlay_history hook handles the pushState call automatically.

§Arguments
  • Signal<bool> - The boolean signal controlling the drawer visibility.
§Returns
  • Option<Rc<dyn Fn(Event)>> - A click event handler that toggles the drawer.
Source

pub fn use_safe_area_fix()

Registers global event listeners that preserve env(safe-area-inset-*) values after exiting any type of fullscreen on Android, and ensures that the system back button exits native fullscreen instead of navigating away.

On initialisation, reads the current env(safe-area-inset-*) pixel values through a sentinel <div> and caches them in thread-local storage. When a fullscreenchange or resize event fires, the cached values are written directly as inline CSS custom properties on the real app root element so that layout never depends on the potentially stale env() function result.

When a native (browser) fullscreen is entered — for example the user taps the fullscreen button on a <video controls> element — a browser history entry is added via overlay_push_state so that the system back gesture will fire popstate. A popstate guard registered via [register_popstate_guard] then calls document.exitFullscreen() to leave fullscreen, consuming the history entry without navigating to the previous route. When the native fullscreen is exited through other means (e.g. the browser’s own exit button), the fullscreenchange handler consumes the extra history entry via overlay_back.

This hook should be called once during app initialization and covers:

  • Native video fullscreen → exit via system back button
  • CSS simulated fullscreen → exit (canvas drawing mode)
  • Any future fullscreen scenarios
Source

pub fn apply_cached_insets()

Writes the cached safe-area inset values as inline CSS custom properties on the real app root element and any fullscreen overlay containers.

Class rules such as c_mobile_app_root, c_app_nav, c_app_main, c_mobile_nav_drawer, and c_canvas_container_fullscreen consume var(--safe-area-inset-top) in their padding declarations. By overriding these CSS custom properties with inline style (which has higher specificity than the stylesheet rule from vars!), all var() references resolve to the cached pixel values, bypassing the stale env() function after a fullscreen exit.

The canvas fullscreen container is position: fixed and outside the app root subtree, so it does not inherit the inline overrides — it must be patched separately.

Trait Implementations§

Source§

impl Clone for UseEuvLayout

Source§

fn clone(&self) -> UseEuvLayout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for UseEuvLayout

Source§

impl Debug for UseEuvLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for UseEuvLayout

Source§

fn default() -> UseEuvLayout

Returns the “default value” for a type. Read more
Source§

impl Eq for UseEuvLayout

Source§

impl Hash for UseEuvLayout

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for UseEuvLayout

Source§

fn cmp(&self, other: &UseEuvLayout) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for UseEuvLayout

Source§

fn eq(&self, other: &UseEuvLayout) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for UseEuvLayout

Source§

fn partial_cmp(&self, other: &UseEuvLayout) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for UseEuvLayout

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more