pub struct UseScroll {
pub x: Signal<f64>,
pub y: Signal<f64>,
/* private fields */
}Expand description
Reactive state for the window’s scroll position.
The handle carries the horizontal and vertical scroll offsets and the teardown that removes the window listener.
The offsets are Signal<f64>: a render closure that reads them
re-renders when the page scrolls.
Fields§
§x: Signal<f64>The horizontal scroll offset in CSS pixels.
y: Signal<f64>The vertical scroll offset in CSS pixels.
Implementations§
Source§impl UseScroll
Inherent implementation of UseScroll.
impl UseScroll
Inherent implementation of UseScroll.
Sourcepub fn current_x(&self) -> f64
pub fn current_x(&self) -> f64
Returns the horizontal offset as a snapshot.
§Returns
f64- The horizontal scroll offset in CSS pixels.
Sourcepub fn scroll_to_top(&self)
pub fn scroll_to_top(&self)
Scrolls the page back to the top.
The scroll is smooth when the browser supports it, so the reader sees the page travel rather than jump.
On a host without a browser this is a no-op.
Source§impl UseScroll
impl UseScroll
pub fn get_x(&self) -> Signal<f64>
pub fn get_mut_x(&mut self) -> &mut Signal<f64>
pub fn set_x(&mut self, val: Signal<f64>) -> &mut Self
pub fn get_y(&self) -> Signal<f64>
pub fn get_mut_y(&mut self) -> &mut Signal<f64>
pub fn set_y(&mut self, val: Signal<f64>) -> &mut Self
pub fn get_mut_teardown(&mut self) -> &mut Rc<RefCell<Option<Box<dyn Fn()>>>>
pub fn set_teardown( &mut self, val: Rc<RefCell<Option<Box<dyn Fn()>>>>, ) -> &mut Self
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for UseScroll
impl !Send for UseScroll
impl !Sync for UseScroll
impl !UnwindSafe for UseScroll
impl Freeze for UseScroll
impl Unpin for UseScroll
impl UnsafeUnpin for UseScroll
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more