forge
Explore
Log in

Don't you dare go Hollow

Add tolerance to view offset anim restart check

Browse files at this commit

22bfec7259282c4e7f629b502e171dbf7580b5a1Ivan MolodetskikhParent: 1af9f9b
It was getting tripped by tiny differences.
src/layout/workspace.rsmodified+10 -4
@@ -771,16 +771,22 @@ impl<W: LayoutElement> Workspace<W> {
771771 let from_view_offset = current_x - new_col_x;
772772 self.view_offset = from_view_offset;
773773
774+ let pixel = 1. / self.scale.fractional_scale();
775+
774776 // If we're already animating towards that, don't restart it.
775- if let Some(ViewOffsetAdjustment::Animation(anim)) = &self.view_offset_adj {
776- let pixel = 1. / self.scale.fractional_scale();
777- if (anim.value() - self.view_offset).abs() < pixel && anim.to() == new_view_offset {
777+ if let Some(ViewOffsetAdjustment::Animation(anim)) = &mut self.view_offset_adj {
778+ let to_diff = new_view_offset - anim.to();
779+ if (anim.value() - self.view_offset).abs() < pixel && to_diff.abs() < pixel {
780+ // Correct for any inaccuracy.
781+ anim.offset(to_diff);
778782 return;
779783 }
780784 }
781785
782786 // If our view offset is already this, we don't need to do anything.
783- if self.view_offset == new_view_offset {
787+ if (self.view_offset - new_view_offset).abs() < pixel {
788+ // Correct for any inaccuracy.
789+ self.view_offset = new_view_offset;
784790 self.view_offset_adj = None;
785791 return;
786792 }