Skip to content

Commit 89d9d27

Browse files
committed
doc comments
1 parent e5c6792 commit 89d9d27

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/components/src/animated_router.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@ use dioxus_router::prelude::{
66

77
#[derive(Clone)]
88
pub enum AnimatedRouterContext<R: Routable + PartialEq> {
9+
/// Transition from one route to another.
910
FromTo(R, R),
11+
/// Settled in a route.
1012
In(R),
1113
}
1214

1315
impl<R: Routable + PartialEq> AnimatedRouterContext<R> {
16+
/// Get the current destination route.
1417
pub fn target_route(&self) -> &R {
1518
match self {
1619
Self::FromTo(_, to) => to,
1720
Self::In(to) => to,
1821
}
1922
}
2023

24+
/// Update the destination route.
2125
pub fn set_target_route(&mut self, to: R) {
2226
match self {
2327
Self::FromTo(old_from, old_to) => {
@@ -28,6 +32,7 @@ impl<R: Routable + PartialEq> AnimatedRouterContext<R> {
2832
}
2933
}
3034

35+
/// After the transition animation has finished, make the outlet only render the destination route.
3136
pub fn settle(&mut self) {
3237
if let Self::FromTo(_, to) = self {
3338
*self = Self::In(to.clone())
@@ -40,6 +45,9 @@ pub struct AnimatedRouterProps {
4045
children: Element,
4146
}
4247

48+
/// Provide a mechanism for outlets to animate between route transitions.
49+
///
50+
/// See the `animated_sidebar.rs` or `animated_tabs.rs` for an example on how to use it.
4351
#[allow(non_snake_case)]
4452
pub fn AnimatedRouter<R: Routable + PartialEq + Clone>(
4553
AnimatedRouterProps { children }: AnimatedRouterProps,
@@ -55,6 +63,7 @@ pub fn AnimatedRouter<R: Routable + PartialEq + Clone>(
5563
rsx!({ children })
5664
}
5765

66+
/// Shortcut to get access to the [AnimatedRouterContext].
5867
pub fn use_animated_router<Route: Routable + PartialEq>() -> Signal<AnimatedRouterContext<Route>> {
5968
use_context()
6069
}

0 commit comments

Comments
 (0)