Skip to main content

Module rotate

Module rotate 

Source
Expand description

Rotate — wraps a child and applies a 2D rotation to its entire subtree, driven by an external Prop<f32> of radians. Layout- stable: the wrapper reports the child’s natural size at all angles; only the visual content rotates within the slot.

let angle = ctx.animated_signal(0.0);
ctx.add(Rotate::new(angle.clone()).child(chevron));
// Animate to 90° on expand:
angle.animate_to(std::f32::consts::FRAC_PI_2, Duration::from_millis(150), Easing::EaseOut);

No internal animation — the caller owns the angle signal and pairs it with Signal::animate_to (or ctx.animate()) for animated rotations. This keeps the widget composable: bind it to interaction state for hover-on rotation, to an animated signal for spinning loaders, to a constant for static decorative rotation.

Use cases: animated chevrons (the disclosure-state pattern, today faked by visibility-toggling two static chevron icons), spinning loaders not covered by Spinner, “shake your head no” rotation feedback, dial controls.

§Reduced motion

Rotate doesn’t introduce motion — it just applies whatever the caller’s angle signal currently holds. Reduced-motion handling belongs at the caller’s animate_to site (use to_or_snap or gate the animation behind prefers_reduced_motion).

Structs§

Rotate
Wraps a child widget and rotates its entire subtree by an externally-driven angle in radians.