Unroll
Unroll — the horizontal sibling of Collapse.
Public types
| Kind | Name |
|---|---|
enum | UnrollFrom — Which edge stays anchored as the child unrolls |
struct | Unroll — Wraps a child widget and reveals or hides it along the horizontal axis by animating the wrapper's reported width between zero and the child's natural width |
Public functions
Unroll
| Returns | Function |
|---|---|
| Constructors | |
Self | new(expanded: Signal<bool>) |
Self | from_progress(progress: Signal<f32>) |
| Builder methods | |
Self | child(widget: impl teksilo_core::IntoTeksiChild) |
Self | child_opt(widget: Option<impl teksilo_core::IntoTeksiChild>) |
Self | reveal_from(from: UnrollFrom) |
| Methods | |
Option<Signal<f32>> | progress_signal() |
Detailed description
Animates a child's width between zero and natural while the child
keeps its full natural layout — the framework's clip pass crops the
overflow, so the visible reveal tracks progress linearly across the
whole duration and the child never reflows mid-animation. This is the
same "lay out full, clip the shrinking axis" trick the docking
Splitter uses for its side expand/collapse (ClipPane).
Two drivers:
Unroll::new(expanded)— self-animated, likeCollapse. Flips between 0 and natural width overMotionTokens::duration_collapsewheneverexpandedtoggles.Unroll::from_progress(progress)— driven by an external animatedSignal<f32>∈ [0, 1]. Use when something else owns the tween — e.g. an overlay whose deferred dismissal rolls the width back into its anchor before going dormant.
The reveal edge is chosen with reveal_from:
UnrollFrom::Leading (default) keeps the leading edge pinned and
grows trailing-ward — the "slide out from a button on the left"
shape; UnrollFrom::Trailing mirrors it.
Honors prefers-reduced-motion: the self-animated driver snaps to
its end value instead of tweening (the external driver's owner is
responsible for its own reduced-motion policy).
#![allow(unused)] fn main() { use teksilo_widgets::animations::{Unroll, UnrollFrom}; use teksilo_widgets::primitives::TextWidget; use teksilo_core::signal::Signal; use teksilo_i18n::lit; let expanded = Signal::new(false); let _w = Unroll::new(expanded) .reveal_from(UnrollFrom::Leading) .child(TextWidget::new(lit!("Reveal me"))); }
API reference
📖 Full rustdoc API for this module
pub enum UnrollFrom
Import: use teksilo::widgets::UnrollFrom;
Which edge stays anchored as the child unrolls.
#![allow(unused)] fn main() { pub enum UnrollFrom { /* variants */ } }
Variants
Leading— Pin the leading edge; reveal trailing-ward (default).Trailing— Pin the trailing edge; reveal leading-ward.
pub struct Unroll
Import: use teksilo::widgets::Unroll;
Wraps a child widget and reveals or hides it along the horizontal axis by animating the wrapper's reported width between zero and the child's natural width. See the module docs for the two available drivers.
#![allow(unused)] fn main() { pub struct Unroll { /* fields */ } }
Methods
pub fn new(expanded: Signal<bool>) -> Self
Self-animated wrapper bound to expanded. Initially rolled up
iff expanded.get() is false at the first build().
pub fn from_progress(progress: Signal<f32>) -> Self
Externally-driven wrapper. progress (an animated 0..1 signal)
is read every layout; the caller owns the tween. Use when an
overlay or other coordinator drives the reveal lifecycle.
pub fn child(mut self, widget: impl teksilo_core::IntoTeksiChild) -> Self
Inline child widget (deferred insertion).
pub fn child_opt(self, widget: Option<impl teksilo_core::IntoTeksiChild>) -> Self
Attach widget when it is Some, and do nothing when it is None.
The conditional-child form. teksu!'s if without an else lowers to
this, and it is what cond.then(|| w) is for in a builder chain. None
adds no arena node, so nothing is laid out, painted, or published to the
accessibility tree, and a stack applies no spacing around it.
pub fn reveal_from(mut self, from: UnrollFrom) -> Self
Set the edge that stays anchored as the child unrolls. Defaults
to UnrollFrom::Leading.
pub fn progress_signal(&self) -> Option<Signal<f32>>
Return the live progress signal (0.0 = rolled up, 1.0 = fully
unrolled). Returns None before the first build(). Useful for
tests and external coordinators that need to observe or gate on
the current animated progress.