pub struct ScrollableContext {
pub scrollable_ref: Signal<Option<Rc<MountedData>>>,
pub scroll_state: Signal<Option<ScrollState>>,
}Expand description
Context provided by the ScrollableView component.
It contains reactive signals for the scroll state and a reference to the underlying DOM element, along with methods to programmatically control scrolling.
Fields§
§scrollable_ref: Signal<Option<Rc<MountedData>>>A reactive signal containing the MountedData of the scrollable container.
scroll_state: Signal<Option<ScrollState>>A reactive signal containing the current ScrollState (dimensions, offset, etc.).
Implementations§
Source§impl ScrollableContext
impl ScrollableContext
Sourcepub async fn reload(&mut self)
pub async fn reload(&mut self)
Forces a re-calculation of the scroll content size and current offset. Useful when the content inside changes but the container’s outer bounds remain the same.
Sourcepub async fn scroll(
&self,
coordinates: PixelsVector2D,
behavior: ScrollBehavior,
)
pub async fn scroll( &self, coordinates: PixelsVector2D, behavior: ScrollBehavior, )
Programmatically scrolls the container by a given offset.
§Example
use dioxus::prelude::*;
use dioxus::html::geometry::PixelsVector2D;
use dioxus_floating::use_scroll_context;
#[component]
fn MyComponent() -> Element {
let ctx = use_scroll_context();
use_effect(move || {
spawn(async move {
ctx.scroll(PixelsVector2D::new(0.0, 100.0), ScrollBehavior::Smooth).await;
});
});
rsx! {}
}Sourcepub async fn scroll_to(&self, behavior: ScrollBehavior)
pub async fn scroll_to(&self, behavior: ScrollBehavior)
Scrolls to a specific position (e.g., top or bottom) based on the behavior.
Sourcepub async fn scroll_to_with_options(&self, options: ScrollToOptions)
pub async fn scroll_to_with_options(&self, options: ScrollToOptions)
Scrolls the container using advanced options (like specific element alignment).
Trait Implementations§
Source§impl Clone for ScrollableContext
impl Clone for ScrollableContext
Source§fn clone(&self) -> ScrollableContext
fn clone(&self) -> ScrollableContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ScrollableContext
impl Debug for ScrollableContext
impl Copy for ScrollableContext
Auto Trait Implementations§
impl Freeze for ScrollableContext
impl !RefUnwindSafe for ScrollableContext
impl !Send for ScrollableContext
impl !Sync for ScrollableContext
impl Unpin for ScrollableContext
impl UnsafeUnpin for ScrollableContext
impl !UnwindSafe for ScrollableContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.