pub fn use_window_scroll<'hook>() -> impl 'hook + Hook<Output = (f64, f64)>Expand description
A sensor hook that tracks Window scroll position.
§Example
use yew_hooks::prelude::*;
#[function_component(UseWindowScroll)]
fn window_scroll() -> Html {
let state = use_window_scroll();
html! {
<>
<b>{ " X: " }</b>
{ state.0 }
<b>{ " Y: " }</b>
{ state.1 }
</>
}
}§Note
When used in function components and hooks, this hook is equivalent to:
/// A sensor hook that tracks Window scroll position.
///
/// # Example
///
/// ```rust
/// # use yew::prelude::*;
/// #
/// use yew_hooks::prelude::*;
///
/// #[function_component(UseWindowScroll)]
/// fn window_scroll() -> Html {
/// let state = use_window_scroll();
///
/// html! {
/// <>
/// <b>{ " X: " }</b>
/// { state.0 }
/// <b>{ " Y: " }</b>
/// { state.1 }
/// </>
/// }
/// }
/// ```
pub fn use_window_scroll() -> (f64, f64) {
/* implementation omitted */
}