Skip to content

Commit

Permalink
chore: Simplify sequential api
Browse files Browse the repository at this point in the history
  • Loading branch information
marc2332 committed Jan 9, 2025
1 parent 47ee90f commit 92fa99c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions crates/hooks/src/use_animation.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{
fmt,
ops::Deref,
time::Duration,
};

Expand Down Expand Up @@ -279,9 +280,13 @@ impl<Animated: AnimatedValue, const N: usize> AnimSequential<Animated, N> {
acc_index: 0,
}
}
}

impl<Animated: AnimatedValue, const N: usize> Deref for AnimSequential<Animated, N> {
type Target = [Animated; N];

pub fn sub(&self, index: usize) -> &Animated {
&self.values[index]
fn deref(&self) -> &Self::Target {
&self.values
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/sequential_animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 92fa99c

Please sign in to comment.