use leptos::prelude::*; use leptos_use::docs::{demo_or_body, Note}; use leptos_use::use_window_scroll; #[component] fn Demo() -> impl IntoView { let (x, y) = use_window_scroll(); let div = document().create_element("div").unwrap(); div.set_attribute( "style", "position: absolute; top: 100%; left: 100%; width: 10000px; height: 10000px;", ) .unwrap(); document().body().unwrap().append_child(&div).unwrap(); view! {
See scroll values in the lower right corner of the screen.
Scroll value
x: {move || format!("{:.1}", x())}
y: {move || format!("{:.1}", y())}
} } fn main() { _ = console_log::init_with_level(log::Level::Debug); console_error_panic_hook::set_once(); mount_to(demo_or_body(), || { view! { } }) }