forge
Explore
Log in

Don't you dare go Hollow

Adjust view offset anim together with offset

Browse files at this commit

e448cfb0efee0efbfc769662ee77ad22a347dc02Ivan MolodetskikhParent: 6aceb3a
Not doing this caused quickly moving a column right and left to base the
final view position on an incorrect view offset.
src/animation/mod.rsmodified+10 -0
@@ -261,6 +261,16 @@ impl Animation {
261 pub fn from(&self) -> f64 {261 pub fn from(&self) -> f64 {
262 self.from262 self.from
263 }263 }
264+
265+ pub fn offset(&mut self, offset: f64) {
266+ self.from += offset;
267+ self.to += offset;
268+
269+ if let Kind::Spring(spring) = &mut self.kind {
270+ spring.from += offset;
271+ spring.to += offset;
272+ }
273+ }
264 }274 }
265 275
266 impl Curve {276 impl Curve {
src/layout/workspace.rsmodified+5 -3
@@ -963,13 +963,15 @@ impl<W: LayoutElement> Workspace<W> {
963 let current_col_x = self.column_x(self.active_column_idx);963 let current_col_x = self.column_x(self.active_column_idx);
964 let next_col_x = self.column_x(self.active_column_idx + 1);964 let next_col_x = self.column_x(self.active_column_idx + 1);
965 965
966- let current_x = current_col_x + self.view_offset;
967-
968 let column = self.columns.remove(self.active_column_idx);966 let column = self.columns.remove(self.active_column_idx);
969 self.columns.insert(new_idx, column);967 self.columns.insert(new_idx, column);
970 968
971 // Preserve the camera position when moving to the left.969 // Preserve the camera position when moving to the left.
972- self.view_offset = current_x - self.column_x(self.active_column_idx);970+ let view_offset_delta = -self.column_x(self.active_column_idx) + current_col_x;
971+ self.view_offset += view_offset_delta;
972+ if let Some(ViewOffsetAdjustment::Animation(anim)) = &mut self.view_offset_adj {
973+ anim.offset(view_offset_delta as f64);
974+ }
973 975
974 // The column we just moved is offset by the difference between its new and old position.976 // The column we just moved is offset by the difference between its new and old position.
975 let new_col_x = self.column_x(new_idx);977 let new_col_x = self.column_x(new_idx);