diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-08-14 15:18:18 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-08-14 15:58:59 +0300 |
| commit | a9f0f4d44f911400ab26d3375dbc2a4015ebb7e5 (patch) | |
| tree | 901ec1e574f7c912b8b251eb56464a1306c39779 /src | |
| parent | e3101ced70b908d4fc9bceef47e878d2de2b4c5d (diff) | |
| download | niri-a9f0f4d44f911400ab26d3375dbc2a4015ebb7e5.tar.gz niri-a9f0f4d44f911400ab26d3375dbc2a4015ebb7e5.tar.bz2 niri-a9f0f4d44f911400ab26d3375dbc2a4015ebb7e5.zip | |
layout/scrolling: Normalize column X move anim from 1 to 0
Will be needed for offsetting to fix the resize cancel issue.
Diffstat (limited to 'src')
| -rw-r--r-- | src/layout/scrolling.rs | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs index 1d43ac56..5dfbb6ef 100644 --- a/src/layout/scrolling.rs +++ b/src/layout/scrolling.rs @@ -176,7 +176,7 @@ pub struct Column<W: LayoutElement> { tab_indicator: TabIndicator, /// Animation of the render offset during window swapping. - move_animation: Option<Animation>, + move_animation: Option<MoveAnimation>, /// Latest known view size for this column's workspace. view_size: Size<f64, Logical>, @@ -254,6 +254,12 @@ pub enum ScrollDirection { Right, } +#[derive(Debug)] +struct MoveAnimation { + anim: Animation, + from: f64, +} + impl<W: LayoutElement> ScrollingSpace<W> { pub fn new( view_size: Size<f64, Logical>, @@ -3878,8 +3884,8 @@ impl<W: LayoutElement> Column<W> { } pub fn advance_animations(&mut self) { - if let Some(anim) = &mut self.move_animation { - if anim.is_done() { + if let Some(move_) = &mut self.move_animation { + if move_.anim.is_done() { self.move_animation = None; } } @@ -3944,8 +3950,8 @@ impl<W: LayoutElement> Column<W> { pub fn render_offset(&self) -> Point<f64, Logical> { let mut offset = Point::from((0., 0.)); - if let Some(anim) = &self.move_animation { - offset.x += anim.value(); + if let Some(move_) = &self.move_animation { + offset.x += move_.from * move_.anim.value(); } offset @@ -3963,15 +3969,16 @@ impl<W: LayoutElement> Column<W> { from_x_offset: f64, config: niri_config::Animation, ) { - let current_offset = self.move_animation.as_ref().map_or(0., Animation::value); - - self.move_animation = Some(Animation::new( - self.clock.clone(), - from_x_offset + current_offset, - 0., - 0., - config, - )); + let current_offset = self + .move_animation + .as_ref() + .map_or(0., |move_| move_.from * move_.anim.value()); + + let anim = Animation::new(self.clock.clone(), 1., 0., 0., config); + self.move_animation = Some(MoveAnimation { + anim, + from: from_x_offset + current_offset, + }); } pub fn contains(&self, window: &W::Id) -> bool { |
