Function leptos_use::use_element_visibility

source ·
pub fn use_element_visibility<El, T>(target: El) -> Signal<bool>
where El: Into<ElementMaybeSignal<T, Element>>, T: Into<Element> + Clone + 'static,
Expand description

Tracks the visibility of an element within the viewport.

§Demo

Link to Demo

§Usage

let el = create_node_ref::<Div>();

let is_visible = use_element_visibility(el);

view! {
    <div node_ref=el>
        <h1>{is_visible}</h1>
    </div>
}

§Server-Side Rendering

On the server this returns a Signal that always contains the value false.

§See also

  • [use_intersection_observer]