Allow scroll_to and snap_to to operate on a single axis
Co-authored-by: Rizzen Yazston <rizzen.yazston@gmail.com>
This commit is contained in:
parent
19569f7900
commit
8e372ce256
3 changed files with 67 additions and 27 deletions
|
|
@ -9,10 +9,13 @@ pub use crate::core::widget::operation::scrollable::{
|
|||
};
|
||||
|
||||
/// Snaps the scrollable with the given [`Id`] to the provided [`RelativeOffset`].
|
||||
pub fn snap_to<T>(id: impl Into<Id>, offset: RelativeOffset) -> Task<T> {
|
||||
pub fn snap_to<T>(
|
||||
id: impl Into<Id>,
|
||||
offset: impl Into<RelativeOffset<Option<f32>>>,
|
||||
) -> Task<T> {
|
||||
task::effect(Action::widget(operation::scrollable::snap_to(
|
||||
id.into(),
|
||||
offset,
|
||||
offset.into(),
|
||||
)))
|
||||
}
|
||||
|
||||
|
|
@ -20,15 +23,18 @@ pub fn snap_to<T>(id: impl Into<Id>, offset: RelativeOffset) -> Task<T> {
|
|||
pub fn snap_to_end<T>(id: impl Into<Id>) -> Task<T> {
|
||||
task::effect(Action::widget(operation::scrollable::snap_to(
|
||||
id.into(),
|
||||
RelativeOffset::END,
|
||||
RelativeOffset::END.into(),
|
||||
)))
|
||||
}
|
||||
|
||||
/// Scrolls the scrollable with the given [`Id`] to the provided [`AbsoluteOffset`].
|
||||
pub fn scroll_to<T>(id: impl Into<Id>, offset: AbsoluteOffset) -> Task<T> {
|
||||
pub fn scroll_to<T>(
|
||||
id: impl Into<Id>,
|
||||
offset: impl Into<AbsoluteOffset<Option<f32>>>,
|
||||
) -> Task<T> {
|
||||
task::effect(Action::widget(operation::scrollable::scroll_to(
|
||||
id.into(),
|
||||
offset,
|
||||
offset.into(),
|
||||
)))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue