forge
Explore
Log in

Don't you dare go Hollow

Fix view offset anim restart on switching focus

Browse files at this commit

2e67152941f9aded7ec81f91f726820cd44e42eaIvan MolodetskikhParent: 22bfec7
src/layout/workspace.rsmodified+6 -2
@@ -768,13 +768,17 @@ impl<W: LayoutElement> Workspace<W> {
768 config: niri_config::Animation,768 config: niri_config::Animation,
769 ) {769 ) {
770 let new_col_x = self.column_x(idx);770 let new_col_x = self.column_x(idx);
771- let from_view_offset = current_x - new_col_x;771+ let old_col_x = current_x - self.view_offset;
772- self.view_offset = from_view_offset;772+ let offset_delta = old_col_x - new_col_x;
773+ self.view_offset += offset_delta;
773 774
774 let pixel = 1. / self.scale.fractional_scale();775 let pixel = 1. / self.scale.fractional_scale();
775 776
776 // If we're already animating towards that, don't restart it.777 // If we're already animating towards that, don't restart it.
777 if let Some(ViewOffsetAdjustment::Animation(anim)) = &mut self.view_offset_adj {778 if let Some(ViewOffsetAdjustment::Animation(anim)) = &mut self.view_offset_adj {
779+ // Offset the animation for the active column change.
780+ anim.offset(offset_delta);
781+
778 let to_diff = new_view_offset - anim.to();782 let to_diff = new_view_offset - anim.to();
779 if (anim.value() - self.view_offset).abs() < pixel && to_diff.abs() < pixel {783 if (anim.value() - self.view_offset).abs() < pixel && to_diff.abs() < pixel {
780 // Correct for any inaccuracy.784 // Correct for any inaccuracy.