pub struct ScrollableAxes {
pub x: Signal<f32>,
pub y: Signal<f32>,
pub max_x: Signal<f32>,
pub max_y: Signal<f32>,
pub overscroll: Signal<Vec2>,
}Expand description
The reactive state one scrollable surface scrolls: where it is on each axis, how far it can go, and how far past the end it is currently being held.
Every field is a Signal, and they are the shared ones — the same handles
a ScrollBar reads and an ensure_visible writes — so this type is a view
onto the widget’s state rather than a second copy of it. Cloning is cloning
handles.
An offset must be Signal::new_animated on a surface that turns
ScrollHandlingOptions::smooth on and gives that axis a range:
animate_to on a plain signal panics. An axis with a permanently zero
range is never written by either path, so a surface that scrolls on one
axis only may leave the other plain.
Fields§
§x: Signal<f32>Horizontal offset, 0.0 at the leading edge.
y: Signal<f32>Vertical offset, 0.0 at the top.
max_x: Signal<f32>Largest legal x — content width minus viewport width, never
below zero.
max_y: Signal<f32>Largest legal y.
overscroll: Signal<Vec2>How far past the range the content is being held right now, per axis,
after the rubber band. Always ZERO under OverscrollStyle::Clamp,
under reduced motion, and outside a live pan.
Published for a surface that wants to draw the stretch or the glow; the offset itself never leaves the range, so a surface that ignores this signal is still correct.
Implementations§
Source§impl ScrollableAxes
impl ScrollableAxes
Sourcepub fn new(
x: Signal<f32>,
y: Signal<f32>,
max_x: Signal<f32>,
max_y: Signal<f32>,
) -> Self
pub fn new( x: Signal<f32>, y: Signal<f32>, max_x: Signal<f32>, max_y: Signal<f32>, ) -> Self
Both axes, with a fresh overscroll signal.
Sourcepub fn vertical(y: Signal<f32>, max_y: Signal<f32>) -> Self
pub fn vertical(y: Signal<f32>, max_y: Signal<f32>) -> Self
A vertical-only surface: the horizontal axis is pinned at zero with a zero range, so nothing can ever move it.
The pinned axis is a plain signal. Both paths write an axis only when its clamp actually moved, and an axis whose range is zero and whose offset is already zero never moves — so the tween that would panic on a plain signal is unreachable here.
Trait Implementations§
Source§impl Clone for ScrollableAxes
impl Clone for ScrollableAxes
Auto Trait Implementations§
impl !RefUnwindSafe for ScrollableAxes
impl !Send for ScrollableAxes
impl !Sync for ScrollableAxes
impl !UnwindSafe for ScrollableAxes
impl Freeze for ScrollableAxes
impl Unpin for ScrollableAxes
impl UnsafeUnpin for ScrollableAxes
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.impl<T> ErasedDestructor for Twhere
T: 'static,
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more