summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-12-18 11:01:20 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-12-18 11:01:20 +0100
commit8245a1176648f8df803f9820bd5ceac71d6a031a (patch)
treed7be32ba81b5f3a5dabb22bc49d59d472959ac73 /native
parent4eb5779542e3d53d2a41f30f259640bb2f8069fd (diff)
downloadiced-8245a1176648f8df803f9820bd5ceac71d6a031a.tar.gz
iced-8245a1176648f8df803f9820bd5ceac71d6a031a.tar.bz2
iced-8245a1176648f8df803f9820bd5ceac71d6a031a.zip
Negate values instead of multipling by `-1.0` in `image::Viewer`
Diffstat (limited to 'native')
-rw-r--r--native/src/widget/image/viewer.rs14
1 files 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),
)
}