Fix width of horizontal scrollbar in Scrollable

This commit is contained in:
Héctor Ramón Jiménez 2023-09-14 19:35:29 +02:00
parent 9245423c5d
commit 2c782bbe7a
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -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,