summaryrefslogtreecommitdiffstats
path: root/widget/src/scrollable.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-14 19:35:29 +0200
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2023-09-14 19:35:29 +0200
commit2c782bbe7a048f6f091e15f68de29a846b9bb059 (patch)
treeddd3de9c89f52624b4c9d23ed6a80cfb3d146c6a /widget/src/scrollable.rs
parent9245423c5d82f88c99adecaaf5dd2ac3559a05a8 (diff)
downloadiced-2c782bbe7a048f6f091e15f68de29a846b9bb059.tar.gz
iced-2c782bbe7a048f6f091e15f68de29a846b9bb059.tar.bz2
iced-2c782bbe7a048f6f091e15f68de29a846b9bb059.zip
Fix width of horizontal scrollbar in `Scrollable`
Diffstat (limited to 'widget/src/scrollable.rs')
-rw-r--r--widget/src/scrollable.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs
index def28821..7b1d7a30 100644
--- a/widget/src/scrollable.rs
+++ b/widget/src/scrollable.rs
@@ -1399,8 +1399,8 @@ impl Scrollbars {
// Need to adjust the width of the horizontal scrollbar if the vertical scrollbar
// is present
- let scrollbar_y_width = show_scrollbar_y
- .map_or(0.0, |v| v.width.max(v.scroller_width) + v.margin);
+ let scrollbar_y_width = y_scrollbar
+ .map_or(0.0, |scrollbar| scrollbar.total_bounds.width);
let total_scrollbar_height =
width.max(scroller_width) + 2.0 * margin;
@@ -1425,12 +1425,12 @@ impl Scrollbars {
let ratio = bounds.width / content_bounds.width;
// min width for easier grabbing with extra wide content
- let scroller_length = (bounds.width * ratio).max(2.0);
- let scroller_offset = translation.x * ratio;
+ let scroller_length = (scrollbar_bounds.width * ratio).max(2.0);
+ let scroller_offset =
+ translation.x * ratio * scrollbar_bounds.width / bounds.width;
let scroller_bounds = Rectangle {
- x: (scrollbar_bounds.x + scroller_offset - scrollbar_y_width)
- .max(0.0),
+ x: (scrollbar_bounds.x + scroller_offset).max(0.0),
y: bounds.y + bounds.height
- total_scrollbar_height / 2.0
- scroller_width / 2.0,