Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibWeb: Make horizontal scrollbar start from the left edge of viewport #1529

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

ronak69
Copy link
Contributor

@ronak69 ronak69 commented Sep 25, 2024

Before:

image

After:

image

Horizontal scrollbar has to leave space at right edge for the vertical
scrollbar to fully extend from top-to-bottom edge of viewport. Before,
this was done by just moving it leftward beyond the edge of viewport.

Now, it gets scaled down appropriately to fit between left edge of
viewport & vertical scrollbar without clipping.
if (scroll_overflow_size == 0)
return {};

auto min_thumb_length = min(scrollport_size, 24);
auto thumb_length = max(scrollport_size * (scrollport_size / scroll_overflow_size), min_thumb_length);
auto scrollbar_rect_length = is_horizontal ? scrollport_size - scrollbar_thumb_thickness : scrollport_size;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why scrollbar_thumb_thickness is subtracted only for horizontal thumb? wouldn't we need the same for vertical?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, only if you leave an empty square at the bottom-right corner where both scrollbars meet. I'm not doing that. Vertical scrollbar has no changes in this patch. Only the horizontal scrollbar is getting changes here.

@kalenikaliaksandr
Copy link
Member

could you provide html or url improved by this change so we could verify it works? I tried some websites but horizontal thumb looked correct there.

@ronak69
Copy link
Contributor Author

ronak69 commented Oct 3, 2024

See the screenshots: before, in the scroll_x = 0 state the scrollbar does not show any rounded end (because it is drawn outside of the screen).

If the thickness is 5% and viewport width is 100%, before horizontal scrollbar is 100% wide and starts at -5% and ends at 95%. Now, it starts at 0% and ends at 95%.

@kalenikaliaksandr kalenikaliaksandr merged commit 8cfe51c into LadybirdBrowser:master Oct 3, 2024
6 checks passed
@ronak69 ronak69 deleted the h-scroll-fit branch October 3, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants