Skip to content

Commit

Permalink
fix: router animations should reset to Start state (closes #1754)
Browse files Browse the repository at this point in the history
  • Loading branch information
gbj committed Sep 30, 2023
1 parent d869bc6 commit 891448d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
33 changes: 27 additions & 6 deletions router/src/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl Animation {
outro,
intro,
intro_back,
finally,
..
} = self;
match current {
Expand All @@ -35,8 +36,10 @@ impl Animation {
AnimationState::Start
} else if intro.is_some() {
AnimationState::Intro
} else {
} else if finally.is_some() {
AnimationState::Finally
} else {
AnimationState::Start
};
(next, true)
}
Expand All @@ -47,21 +50,37 @@ impl Animation {
AnimationState::IntroBack
} else if intro.is_some() {
AnimationState::Intro
} else {
} else if finally.is_some() {
AnimationState::Finally
} else {
AnimationState::Start
};
(next, true)
}
AnimationState::Start => {
let next = if intro.is_some() {
AnimationState::Intro
} else {
} else if finally.is_some() {
AnimationState::Finally
} else {
AnimationState::Start
};
(next, false)
}
AnimationState::Intro => (AnimationState::Finally, false),
AnimationState::IntroBack => (AnimationState::Finally, false),
AnimationState::Intro => {
if finally.is_some() {
(AnimationState::Finally, false)
} else {
(AnimationState::Start, false)
}
}
AnimationState::IntroBack => {
if finally.is_some() {
(AnimationState::Finally, false)
} else {
(AnimationState::Start, false)
}
}
AnimationState::Finally => {
if outro.is_some() {
if is_back {
Expand All @@ -77,8 +96,10 @@ impl Animation {
} else {
(AnimationState::Intro, false)
}
} else {
} else if finally.is_some() {
(AnimationState::Finally, true)
} else {
(AnimationState::Start, true)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion router/src/components/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub fn AnimatedRoutes(
};
let is_back = use_is_back_navigation();
let (animation_state, set_animation_state) =
create_signal(AnimationState::Finally);
create_signal(AnimationState::Start);
let next_route = router.pathname();

let is_complete = Rc::new(Cell::new(true));
Expand All @@ -190,6 +190,7 @@ pub fn AnimatedRoutes(
move |prev: Option<&(AnimationState, String)>| {
let animation_state = animation_state.get();
let next_route = next_route.get();
logging::log!("{animation_state:?} {next_route:?}");
let prev_matches = prev
.map(|(_, r)| r)
.cloned()
Expand Down

0 comments on commit 891448d

Please sign in to comment.