forge
Explore
Log in

Don't you dare go Hollow

Member arrive is one animation: grow first, then the glow lights the full-size row and fades

Browse files at this commit

cf285c30ff42ea6c167e017b972b610ff9a0455bAhmet Kaan GümüşParent: 234db48
  • style
    • member arrive is one animation: grow first, then the glow lights the full-size row and fades
Show full message
💄 style: member arrive is one animation: grow first, then the glow lights the full-size row and fades
crates/client/src/gui/chat.rsmodified+18 -16
@@ -3097,7 +3097,7 @@ impl Moves {
30973097 self.places
30983098 .get(&user_id)
30993099 .and_then(|(_, from)| *from)
3100- .is_some_and(|(_, at)| now - at < GLOW)
3100+ .is_some_and(|(_, at)| now - at < ARRIVE)
31013101 }
31023102
31033103 fn left(&self, place: Place, now: Instant) -> usize {
@@ -3110,7 +3110,7 @@ impl Moves {
31103110 }
31113111
31123112 const GROW: Duration = Duration::from_millis(160);
3113-const GLOW: Duration = Duration::from_millis(900);
3113+const ARRIVE: Duration = Duration::from_millis(1060);
31143114 const ROW_MAX: f32 = size::CONTROL * 2.;
31153115
31163116 fn members_column(
@@ -3257,22 +3257,24 @@ fn members_column(
32573257 }
32583258 let place = member.place();
32593259 let glow = palette.accent;
3260+ let grown = GROW.as_secs_f32() / ARRIVE.as_secs_f32();
32603261 div()
32613262 .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))
32723265 .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+ },
32763278 )
32773279 .into_any_element()
32783280 };
@@ -3907,7 +3909,7 @@ mod tests {
39073909 moves.track(1, &[member(7, true)], start);
39083910 assert!(moves.moved(7, start));
39093911 assert_eq!(moves.left(Place::Online, start), 1);
3910- assert!(!moves.moved(7, start + GLOW));
3912+ assert!(!moves.moved(7, start + ARRIVE));
39113913 assert_eq!(moves.left(Place::Online, start + GROW), 0);
39123914 moves.track(2, &[member(7, false)], start);
39133915 assert!(!moves.moved(7, start));