diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-08-12 22:34:13 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-08-14 15:58:59 +0300 |
| commit | e3101ced70b908d4fc9bceef47e878d2de2b4c5d (patch) | |
| tree | 60962874a6544f43a2531e064d104c150cde96b1 /src/layout/scrolling.rs | |
| parent | ea438b21e933d45672e80ca04db42eb54050fcca (diff) | |
| download | niri-e3101ced70b908d4fc9bceef47e878d2de2b4c5d.tar.gz niri-e3101ced70b908d4fc9bceef47e878d2de2b4c5d.tar.bz2 niri-e3101ced70b908d4fc9bceef47e878d2de2b4c5d.zip | |
layout: Offset Y animations for non-animated resizes
Diffstat (limited to 'src/layout/scrolling.rs')
| -rw-r--r-- | src/layout/scrolling.rs | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs index 94f2aa97..1d43ac56 100644 --- a/src/layout/scrolling.rs +++ b/src/layout/scrolling.rs @@ -4056,12 +4056,35 @@ impl<W: LayoutElement> Column<W> { // windows in the column, so they should all be animated. How should this interact with // animated vs. non-animated resizes? For example, an animated +20 resize followed by two // non-animated -10 resizes. - if !is_tabbed && tile.resize_animation().is_some() && offset != 0. { - for tile in &mut self.tiles[tile_idx + 1..] { - tile.animate_move_y_from_with_config( - offset, - self.options.animations.window_resize.anim, - ); + if !is_tabbed && offset != 0. { + if tile.resize_animation().is_some() { + // If there's a resize animation (that may have just started in + // tile.update_window()), then the apparent size change is smooth with no sudden + // jumps. This corresponds to adding an Y animation to tiles below. + for tile in &mut self.tiles[tile_idx + 1..] { + tile.animate_move_y_from_with_config( + offset, + self.options.animations.window_resize.anim, + ); + } + } else { + // There's no resize animation, but the offset is nonzero. This could happen for + // example: + // - if the window resized on its own, which we don't animate + // - if the window resized by less than 10 px (the resize threshold) + // + // The latter case could also cancel an ongoing resize animation. + // + // Now, stationary tiles below shouldn't react to this offset change in any way, + // i.e. their apparent Y position should jump together with the resize. However, + // tiles below that are already animating an Y movement should offset their + // animations to avoid the jump. + // + // Notably, this is necessary to fix the animation jump when resizing height back + // and forth in quick succession (in a way that cancels the resize animation). + for tile in &mut self.tiles[tile_idx + 1..] { + tile.offset_move_y_anim_current(offset); + } } } } |
