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> {
771 let from_view_offset = current_x - new_col_x;771 let from_view_offset = current_x - new_col_x;
772 self.view_offset = from_view_offset;772 self.view_offset = from_view_offset;
773 773
774+ let pixel = 1. / self.scale.fractional_scale();
775+
774 // If we're already animating towards that, don't restart it.776 // If we're already animating towards that, don't restart it.
775- if let Some(ViewOffsetAdjustment::Animation(anim)) = &self.view_offset_adj {777+ if let Some(ViewOffsetAdjustment::Animation(anim)) = &mut self.view_offset_adj {
776- let pixel = 1. / self.scale.fractional_scale();778+ let to_diff = new_view_offset - anim.to();
777- if (anim.value() - self.view_offset).abs() < pixel && anim.to() == new_view_offset {779+ if (anim.value() - self.view_offset).abs() < pixel && to_diff.abs() < pixel {
780+ // Correct for any inaccuracy.
781+ anim.offset(to_diff);
778 return;782 return;
779 }783 }
780 }784 }
781 785
782 // If our view offset is already this, we don't need to do anything.786 // 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;
784 self.view_offset_adj = None;790 self.view_offset_adj = None;
785 return;791 return;
786 }792 }