Member arrive is one animation: grow first, then the glow lights the full-size row and fades
Browse files at this commitcf285c30ff42ea6c167e017b972b610ff9a0455bParent: 234db48- style
- member arrive is one animation: grow first, then the glow lights the full-size row and fades
1 changed file +18 -16
- crates/client/src/gui/chat.rs +18 -16
crates/client/src/gui/chat.rsmodified+18 -16
| @@ -3097,7 +3097,7 @@ impl Moves { | ||
| 3097 | 3097 | self.places |
| 3098 | 3098 | .get(&user_id) |
| 3099 | 3099 | .and_then(|(_, from)| *from) |
| 3100 | - .is_some_and(|(_, at)| now - at < GLOW) | |
| 3100 | + .is_some_and(|(_, at)| now - at < ARRIVE) | |
| 3101 | 3101 | } |
| 3102 | 3102 | |
| 3103 | 3103 | fn left(&self, place: Place, now: Instant) -> usize { |
| @@ -3110,7 +3110,7 @@ impl Moves { | ||
| 3110 | 3110 | } |
| 3111 | 3111 | |
| 3112 | 3112 | const GROW: Duration = Duration::from_millis(160); |
| 3113 | -const GLOW: Duration = Duration::from_millis(900); | |
| 3113 | +const ARRIVE: Duration = Duration::from_millis(1060); | |
| 3114 | 3114 | const ROW_MAX: f32 = size::CONTROL * 2.; |
| 3115 | 3115 | |
| 3116 | 3116 | fn members_column( |
| @@ -3257,22 +3257,24 @@ fn members_column( | ||
| 3257 | 3257 | } |
| 3258 | 3258 | let place = member.place(); |
| 3259 | 3259 | let glow = palette.accent; |
| 3260 | + let grown = GROW.as_secs_f32() / ARRIVE.as_secs_f32(); | |
| 3260 | 3261 | div() |
| 3261 | 3262 | .overflow_hidden() |
| 3262 | - .child( | |
| 3263 | - div() | |
| 3264 | - .rounded(px(radius::MD)) | |
| 3265 | - .child(row(member)) | |
| 3266 | - .with_animation( | |
| 3267 | - format!("member_glow_{user_id}_{place:?}"), | |
| 3268 | - gpui_kit::Animation::new(GLOW).with_easing(gpui_kit::ease_in_out), | |
| 3269 | - move |row, delta| row.bg(glow.opacity(0.24 * (1. - delta))), | |
| 3270 | - ), | |
| 3271 | - ) | |
| 3263 | + .rounded(px(radius::MD)) | |
| 3264 | + .child(row(member)) | |
| 3272 | 3265 | .with_animation( |
| 3273 | - format!("member_grow_{user_id}_{place:?}"), | |
| 3274 | - gpui_kit::Animation::new(GROW).with_easing(gpui_kit::ease_out_quint()), | |
| 3275 | - |row, delta| row.max_h(px(delta * ROW_MAX)), | |
| 3266 | + format!("member_arrive_{user_id}_{place:?}"), | |
| 3267 | + gpui_kit::Animation::new(ARRIVE), | |
| 3268 | + move |row, delta| { | |
| 3269 | + let grow = gpui_kit::ease_out_quint()((delta / grown).min(1.)); | |
| 3270 | + let fade = ((delta - grown) / (1. - grown)).max(0.); | |
| 3271 | + let row = row.max_h(px(grow * ROW_MAX)); | |
| 3272 | + if delta < grown { | |
| 3273 | + row | |
| 3274 | + } else { | |
| 3275 | + row.bg(glow.opacity(0.24 * (1. - fade))) | |
| 3276 | + } | |
| 3277 | + }, | |
| 3276 | 3278 | ) |
| 3277 | 3279 | .into_any_element() |
| 3278 | 3280 | }; |
| @@ -3907,7 +3909,7 @@ mod tests { | ||
| 3907 | 3909 | moves.track(1, &[member(7, true)], start); |
| 3908 | 3910 | assert!(moves.moved(7, start)); |
| 3909 | 3911 | assert_eq!(moves.left(Place::Online, start), 1); |
| 3910 | - assert!(!moves.moved(7, start + GLOW)); | |
| 3912 | + assert!(!moves.moved(7, start + ARRIVE)); | |
| 3911 | 3913 | assert_eq!(moves.left(Place::Online, start + GROW), 0); |
| 3912 | 3914 | moves.track(2, &[member(7, false)], start); |
| 3913 | 3915 | assert!(!moves.moved(7, start)); |