use leptos::*; use leptos_use::docs::{demo_or_body, BooleanDisplay}; use leptos_use::{ use_intersection_observer_with_options, UseIntersectionObserverOptions, UseIntersectionObserverReturn, }; #[component] fn Demo(cx: Scope) -> impl IntoView { let root = create_node_ref(cx); let target = create_node_ref(cx); let (is_visible, set_visible) = create_signal(cx, false); let UseIntersectionObserverReturn { is_active, pause, resume, .. } = use_intersection_observer_with_options( cx, target, move |entries, _| { set_visible.set(entries[0].is_intersecting()); }, UseIntersectionObserverOptions::default().root(Some(root)), ); view! { cx,

"Scroll me down!"

"Hello world!"

"Element " " the viewport"
} } fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); mount_to(demo_or_body(), |cx| { view! { cx, } }) }