From 92fa99c1ca2650e03d5229bc96260c964e6f0c3d Mon Sep 17 00:00:00 2001 From: marc2332 Date: Thu, 9 Jan 2025 10:18:03 +0100 Subject: [PATCH] chore: Simplify sequential api --- crates/hooks/src/use_animation.rs | 9 +++++++-- examples/sequential_animation.rs | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/hooks/src/use_animation.rs b/crates/hooks/src/use_animation.rs index 154e6adb1..9f5718367 100644 --- a/crates/hooks/src/use_animation.rs +++ b/crates/hooks/src/use_animation.rs @@ -1,5 +1,6 @@ use std::{ fmt, + ops::Deref, time::Duration, }; @@ -279,9 +280,13 @@ impl AnimSequential { acc_index: 0, } } +} + +impl Deref for AnimSequential { + type Target = [Animated; N]; - pub fn sub(&self, index: usize) -> &Animated { - &self.values[index] + fn deref(&self) -> &Self::Target { + &self.values } } diff --git a/examples/sequential_animation.rs b/examples/sequential_animation.rs index 8b0494e88..e696cbc15 100644 --- a/examples/sequential_animation.rs +++ b/examples/sequential_animation.rs @@ -26,8 +26,8 @@ fn app() -> Element { let sequential = animations.get(); - let rotate_a = sequential.read().sub(0).read(); - let rotate_b = sequential.read().sub(1).read(); + let rotate_a = sequential.read()[0].read(); + let rotate_b = sequential.read()[1].read(); rsx!( rect {