pub struct LayoutAnimationConfig {
pub stable_key: Option<String>,
pub height: bool,
pub width: bool,
pub x: bool,
pub y: bool,
pub spring: SpringConfig,
pub threshold: f32,
}Use VisualAnimationConfig from visual_animation module. The old system modifies taffy which causes issues.
Expand description
Configuration for which layout properties to animate
ยงDeprecated
Use VisualAnimationConfig instead.
The new system uses FLIP-style animations that never modify the layout tree.
Fieldsยง
ยงstable_key: Option<String>Use VisualAnimationConfig from visual_animation module. The old system modifies taffy which causes issues.
Stable key for tracking this animation across rebuilds
When set, the animation state is tracked by this key instead of node ID. This allows animations to persist when Stateful components rebuild, creating new nodes but representing the same logical element.
height: boolUse VisualAnimationConfig from visual_animation module. The old system modifies taffy which causes issues.
Animate height changes
width: boolUse VisualAnimationConfig from visual_animation module. The old system modifies taffy which causes issues.
Animate width changes
x: boolUse VisualAnimationConfig from visual_animation module. The old system modifies taffy which causes issues.
Animate x position changes
y: boolUse VisualAnimationConfig from visual_animation module. The old system modifies taffy which causes issues.
Animate y position changes
spring: SpringConfigUse VisualAnimationConfig from visual_animation module. The old system modifies taffy which causes issues.
Spring configuration for the animation
threshold: f32Use VisualAnimationConfig from visual_animation module. The old system modifies taffy which causes issues.
Minimum change threshold in pixels (ignore tiny changes)
Implementationsยง
Sourceยงimpl LayoutAnimationConfig
impl LayoutAnimationConfig
Sourcepub fn height() -> LayoutAnimationConfig
pub fn height() -> LayoutAnimationConfig
Animate only height changes (most common for accordions/collapsibles)
Sourcepub fn width() -> LayoutAnimationConfig
pub fn width() -> LayoutAnimationConfig
Animate only width changes
Sourcepub fn size() -> LayoutAnimationConfig
pub fn size() -> LayoutAnimationConfig
Animate both width and height changes
Sourcepub fn position() -> LayoutAnimationConfig
pub fn position() -> LayoutAnimationConfig
Animate only position changes (x, y)
Sourcepub fn all() -> LayoutAnimationConfig
pub fn all() -> LayoutAnimationConfig
Animate all bounds (position and size)
Sourcepub fn with_key(self, key: impl Into<String>) -> LayoutAnimationConfig
pub fn with_key(self, key: impl Into<String>) -> LayoutAnimationConfig
Set a stable key for tracking this animation across rebuilds
This is essential when using layout animation inside Stateful components, since node IDs change on rebuild. The stable key allows the animation system to recognize โthis is the same logical elementโ and animate from the previous bounds to the new bounds.
ยงExample
div()
.animate_layout(
LayoutAnimationConfig::height()
.with_key("accordion-item-1")
.snappy()
)Sourcepub fn with_spring(self, spring: SpringConfig) -> LayoutAnimationConfig
pub fn with_spring(self, spring: SpringConfig) -> LayoutAnimationConfig
Set the spring configuration
Sourcepub fn with_threshold(self, threshold: f32) -> LayoutAnimationConfig
pub fn with_threshold(self, threshold: f32) -> LayoutAnimationConfig
Set the minimum change threshold
Changes smaller than this value (in pixels) will not trigger animation.
Sourcepub fn gentle(self) -> LayoutAnimationConfig
pub fn gentle(self) -> LayoutAnimationConfig
Use a gentle spring (slow, smooth)
Sourcepub fn wobbly(self) -> LayoutAnimationConfig
pub fn wobbly(self) -> LayoutAnimationConfig
Use a wobbly spring (with overshoot)
Sourcepub fn stiff(self) -> LayoutAnimationConfig
pub fn stiff(self) -> LayoutAnimationConfig
Use a stiff spring (quick, snappy)
Sourcepub fn snappy(self) -> LayoutAnimationConfig
pub fn snappy(self) -> LayoutAnimationConfig
Use a snappy spring (very responsive)
Trait Implementationsยง
Sourceยงimpl Clone for LayoutAnimationConfig
impl Clone for LayoutAnimationConfig
Sourceยงfn clone(&self) -> LayoutAnimationConfig
fn clone(&self) -> LayoutAnimationConfig
1.0.0 (const: unstable) ยท Sourceยงfn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSourceยงimpl Debug for LayoutAnimationConfig
impl Debug for LayoutAnimationConfig
Sourceยงimpl Default for LayoutAnimationConfig
impl Default for LayoutAnimationConfig
Sourceยงfn default() -> LayoutAnimationConfig
fn default() -> LayoutAnimationConfig
Auto Trait Implementationsยง
impl Freeze for LayoutAnimationConfig
impl RefUnwindSafe for LayoutAnimationConfig
impl Send for LayoutAnimationConfig
impl Sync for LayoutAnimationConfig
impl Unpin for LayoutAnimationConfig
impl UnsafeUnpin for LayoutAnimationConfig
impl UnwindSafe for LayoutAnimationConfig
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.