diff --git a/src/animate/animation.rs b/src/animate/animation.rs index ff55c383..1b1e203e 100644 --- a/src/animate/animation.rs +++ b/src/animate/animation.rs @@ -84,7 +84,7 @@ pub enum Animate { #[derive(Clone)] pub struct Animation { pub(crate) state: AnimState, - pub(crate) view_state: RwSignal); 1]>>, + pub(crate) view_state: SmallVec<[RwSignal); 1]>>; 1]>, // This easing is used for when animating towards the default style (the style before the animation is applied). // pub(crate) easing: Easing, pub(crate) auto_reverse: bool, @@ -107,7 +107,7 @@ impl Default for Animation { fn default() -> Self { Animation { state: AnimState::Idle, - view_state: RwSignal::new(SmallVec::new()), + view_state: SmallVec::new_const(), auto_reverse: false, delay: Duration::ZERO, duration: Duration::from_secs(1), @@ -307,9 +307,10 @@ impl Animation { command: impl Fn() -> AnimStateCommand + 'static, apply_inital: bool, ) -> Self { - let view_state = self.view_state; + let states = RwSignal::new(SmallVec::new_const()); + self.view_state.push(states); let initial_command = create_updater(command, move |command| { - for (view_id, stack_offset) in view_state.get_untracked() { + for (view_id, stack_offset) in states.get_untracked() { view_id.update_animation_state(stack_offset, command) } }); diff --git a/src/id.rs b/src/id.rs index a2d34cb7..afd2c63a 100644 --- a/src/id.rs +++ b/src/id.rs @@ -6,7 +6,6 @@ use std::{any::Any, cell::RefCell, rc::Rc}; -use floem_reactive::SignalUpdate; use floem_winit::window::WindowId; use peniko::kurbo::{Insets, Point, Rect, Size}; use slotmap::new_key_type; @@ -335,9 +334,6 @@ impl ViewId { pub(crate) fn update_animation(&self, offset: StackOffset, animation: Animation) { let state = self.state(); - animation - .view_state - .update(move |stack| stack.push((*self, offset))); state.borrow_mut().animation.set(offset, animation); self.request_style(); } diff --git a/src/views/decorator.rs b/src/views/decorator.rs index ceae074c..7317bd68 100644 --- a/src/views/decorator.rs +++ b/src/views/decorator.rs @@ -322,9 +322,10 @@ pub trait Decorators: IntoView + Sized { view_id.update_animation(offset, animation); }, ); - initial_animation - .view_state - .update(|stack| stack.push((view_id, offset))); + for effect_state in &initial_animation.view_state { + effect_state.update(|stack| stack.push((view_id, offset))); + } + state.borrow_mut().animation.push(initial_animation); view