From 8245a1176648f8df803f9820bd5ceac71d6a031a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Fri, 18 Dec 2020 11:01:20 +0100 Subject: [PATCH] Negate values instead of multipling by `-1.0` in `image::Viewer` --- native/src/widget/image/viewer.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/native/src/widget/image/viewer.rs b/native/src/widget/image/viewer.rs index 605298f1..62745fba 100644 --- a/native/src/widget/image/viewer.rs +++ b/native/src/widget/image/viewer.rs @@ -383,13 +383,13 @@ impl State { if bounds.width < image_size.width { self.current_offset.x = (self.starting_offset.x - delta_x) .min(hidden_width) - .max(-1.0 * hidden_width); + .max(-hidden_width); } if bounds.height < image_size.height { self.current_offset.y = (self.starting_offset.y - delta_y) .min(hidden_height) - .max(-1.0 * hidden_height); + .max(-hidden_height); } } @@ -406,14 +406,8 @@ impl State { (image_size.height - bounds.height / 2.0).max(0.0).round(); Vector::new( - self.current_offset - .x - .min(hidden_width) - .max(-1.0 * hidden_width), - self.current_offset - .y - .min(hidden_height) - .max(-1.0 * hidden_height), + self.current_offset.x.min(hidden_width).max(-hidden_width), + self.current_offset.y.min(hidden_height).max(-hidden_height), ) }