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

Make one pixel beyond the scrollbar thumb react correctly to clicks #505

Merged
merged 2 commits into from Apr 28, 2023

Conversation

m-sasha
Copy link

@m-sasha m-sasha commented Apr 12, 2023

The detection of scrollbar track clicks used the scrollbar thumb's "raw" (floating-point) bounds. However, this misses the first pixel after the thumb, because, for example, the value 10 is in the floating point range 0..10.0, but the actual pixel bounds of the thumb for that range would not include the 10th pixel (the size of the thumb would be 10px, so its pixel range would be 0px..9px).

Proposed Changes

Size the scrollbar in integer pixels and use that size when detecting clicks on the scrollbar track (outsize the thumb).

Testing

Test: Added a new unit test to test the last pixel (and one beyond) of the thumb, and fixed other tests which used to pass because the one-pixel-beyond the thumb was neither clickable nor draggable.

@m-sasha m-sasha requested a review from igordmn April 12, 2023 10:26
@m-sasha m-sasha changed the title Make one pixel beyond the scrollbar thumb react correctly to clicks. Make one pixel beyond the scrollbar thumb react correctly to clicks Apr 12, 2023
@m-sasha m-sasha requested a review from MatkovIvan April 27, 2023 21:02
Copy link
Member

@MatkovIvan MatkovIvan left a comment

Choose a reason for hiding this comment

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

The code LGTM, just some formatting nitpicks.

But I cannot note the difference in the test app 🤷‍♂️

@m-sasha
Copy link
Author

m-sasha commented Apr 28, 2023

@MatkovIvan What do you mean by test app? The change is only about one row of pixels, so it's hard to notice in a real app. It's noticeable in unit tests, though.

@m-sasha m-sasha force-pushed the m-sasha/scrollbar-thumb-last-pixel branch from a4a050f to 4bdd0a1 Compare April 28, 2023 08:45
@m-sasha m-sasha merged commit ff5416a into jb-main Apr 28, 2023
1 of 2 checks passed
@m-sasha m-sasha deleted the m-sasha/scrollbar-thumb-last-pixel branch April 28, 2023 12:02
eymar pushed a commit that referenced this pull request May 25, 2023
…aging-compose

In Multiplatform Paging, the classes `DirectDispatcher` and `TestDispatcher` in `testutils-ktx` had to be multiplatformized to allow dependent tests in `paging-compose`, `paging-common`, and `paging-runtime` to be moved to the respective `commonTest` folders.

I'm attempting to replace all usages of `DirectDispatcher` and `TestDispatcher` that Multiplatform Paging depends on with those found in `kotlinx.coroutines.test`, so hopefully the `testutils-ktx` dependency no longer has to be multiplatformized in my fork.

I'm starting this effort by doing it with `paging-compose`.

Test: ./gradlew test connectedCheck
Bug: 270612487

This is an imported pull request from androidx#505.

Resolves #505
Github-Pr-Head-Sha: 002b706
GitOrigin-RevId: 2b32273
Change-Id: Id018cf4bf64dac3154eff2ea98e6145aff4290fc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants