Skip to main content

Module animations

Module animations 

Source
Expand description

ReactUiAnimationsPlugin — a Reanimated-style animation engine for bevy-react.

The model mirrors React Native’s Reanimated: a React app declares shared values (one animatable f32 with a stable id) and assigns drivers (withTiming, withSpring, withRepeat, withSequence) to them; an Animated.node binds style properties to those values. All per-frame work — advancing drivers, interpolation, writing components — happens here, on the Bevy side, never crossing back to JS. The one exception is completion: a driver started with a correlation token reports its settlement (one AnimationSettled message, forwarded by the integrator) so a JS callback can fire — once per animation, not per frame.

This crate is deliberately decoupled from the main bevy-react crate (which depends on it): it owns the animation wire types (protocol) and the orchestration systems, and receives commands through an AnimationInbox channel the integrator hands it.

Re-exports§

pub use protocol::AnimatableProperty;
pub use protocol::AnimatedBindings;
pub use protocol::AnimationCommand;
pub use protocol::Binding;
pub use protocol::Driver;
pub use protocol::Easing;
pub use protocol::SharedId;
pub use protocol::ValueKind;

Modules§

protocol
Wire types for the animation bridge — the Reanimated-style surface a React app declares once and the Bevy side drives every frame.

Structs§

AnimatedNode
Component placed (by the main reconciler) on any Animated.node. Carries the property→Binding map. Requires UiTransform so the apply system can always drive it.
AnimationInbox
The receiving end of the op_animate channel, drained each frame.
AnimationSettled
A token-tagged driver settled: finished is true when it ran to its natural end, false when a set/cancel/new animate interrupted it. Written by the drain/tick systems for every AnimationCommand::Animate that carried a token; the integrator (bevy-react) forwards these to the JS completion callbacks. The one thing this crate sends back toward JS.
ReactUiAnimationsPlugin
Adds the animation orchestration: the SharedValues table, the per-frame driver/apply systems, and the AnimationInbox that feeds commands in.
SharedValues
The live table of shared values, keyed by SharedId. Each entry holds the current reading plus an optional active driver. Settlements of token-tagged drivers accumulate in settled until the owning system flushes them to the AnimationSettled message stream.

Enums§

AnimationSet
Ordering handles for the three animation systems. The integrator orders AnimationSet::Apply relative to its own reconciler systems.
Runner
The stateful evaluation of a Driver over time. Built from a driver + the value’s live reading; advanced by Runner::step.

Traits§

Lerp
Linear interpolation between two values of the same kind, t in 0.0..=1.0. The one primitive every interpolated quantity shares — implemented here for the scalar and color bindings, and by bevy-react’s transition engine for its own channel types (hence public).

Functions§

build_runner
Build a Runner for driver starting from the value from. Public for the bevy-react transition engine (see Runner).
build_ui_transform
Build a UiTransform from the six scalar transform channels (each None stays at identity: no translation, unit scale, no rotation). scale is uniform; scale_x/scale_y override a single axis. Shared by the animated node apply and bevy-react’s static/transition transform path so the channel semantics stay identical across both.