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

"Scroll me down!"

"Hello world!"

"Element " " the viewport"
} } fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); let unmount_handle = leptos::mount::mount_to(demo_or_body(), || { view! { } }); unmount_handle.forget(); }