shell: Delay alpha changes for minimize animations

This commit is contained in:
Victoria Brekenfeld 2024-02-29 17:50:05 +01:00 committed by Victoria Brekenfeld
parent e669396fd5
commit 625218bbf6
2 changed files with 13 additions and 6 deletions

View file

@ -90,18 +90,20 @@ impl Animation {
match self {
Animation::Tiled { .. } => 1.0,
Animation::Minimize { start, .. } => {
1.0 - (Instant::now()
let percentage = Instant::now()
.duration_since(*start)
.min(MINIMIZE_ANIMATION_DURATION)
.as_secs_f32()
/ MINIMIZE_ANIMATION_DURATION.as_secs_f32())
/ MINIMIZE_ANIMATION_DURATION.as_secs_f32();
1.0 - ((percentage - 0.5).max(0.0) * 2.0)
}
Animation::Unminimize { start, .. } => {
Instant::now()
let percentage = Instant::now()
.duration_since(*start)
.min(MINIMIZE_ANIMATION_DURATION)
.as_secs_f32()
/ MINIMIZE_ANIMATION_DURATION.as_secs_f32()
/ MINIMIZE_ANIMATION_DURATION.as_secs_f32();
(percentage * 2.0).min(1.0)
}
}
}