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

Fix scroll handle overlap #5286

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gilbertoalexsantos
Copy link

Info

This PR addresses an issue where resizing a scroll handle can lead to unwanted overlap.

It is also happening on the egui-demo.

Screenshot 2024-10-18 at 17 35 25

Cause

Note: The following explanation assumes a vertical scroll; however, the logic applies equally to horizontal scrolling.

When the scroll handle is positioned at the top or bottom of the scroll area and the handle is resized to fit the minimum handle size, there is a risk of overlap. This occurs if the handle’s new size extends beyond the bounds of the scroll area.

Proposed Solution

  1. Check whether increasing the handle size will cause it to overlap with the scroll area.
  2. If an overlap is detected, adjust the handle’s center position by the overlap amount, moving it towards the center of the scroll area.

Copy link

Preview available at https://egui-pr-preview.github.io/pr/5286-fix-scroll-handle-overlap
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

@lucasmerlin
Copy link
Collaborator

While this is a improvement, now it will look like you're at the top while already scrolled done by some amount:

Bildschirmaufnahme.2024-10-20.um.17.22.48.mov

Ideally, the scrollbar position would just be calculated correctly, taking the min size into account.

@lucasmerlin lucasmerlin added egui bug Something is broken labels Oct 20, 2024
@gilbertoalexsantos
Copy link
Author

@lucasmerlin

Oh, you're totally right. I didn't notice this behaviour 🥲

I'll work on a fix for this ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScrollArea's scrollbar goes past frame's borders
2 participants