Skip to main content

Module unroll

Module unroll 

Source
Expand description

Unroll — the horizontal sibling of Collapse.

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, like Collapse. Flips between 0 and natural width over MotionTokens::duration_collapse whenever expanded toggles.
  • Unroll::from_progress(progress) — driven by an external animated Signal<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).

let expanded = Signal::new(false);
let _w = Unroll::new(expanded)
    .reveal_from(UnrollFrom::Leading)
    .child(TextWidget::new(lit!("Reveal me")));

Structs§

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.

Enums§

UnrollFrom
Which edge stays anchored as the child unrolls.