Skip to content

Fix asymmetric behavior of scroll direction - #443

Merged
koron merged 1 commit into
Yowkees:mainfrom
MiSawa:fix/scroll-factor
Mar 21, 2024
Merged

Fix asymmetric behavior of scroll direction#443
koron merged 1 commit into
Yowkees:mainfrom
MiSawa:fix/scroll-factor

Conversation

@MiSawa

@MiSawa MiSawa commented Dec 9, 2023

Copy link
Copy Markdown
Contributor

When the scroll div is sufficiently large, you'll see a weird asymmetric behavior of scrolling; when you scroll towards the positive direction, the actual scroll happens after some ball movement, but when you scroll towards the negative direction, the scroll happens with a little ball movement.
This happens because the behavior of right shift >> div is not symmetric for positive and negative lhs. For example, 1 >> 3 is zero, but -1 >> 3 is -1. https://wandbox.org/permlink/M943OJ3soMrS4uH6

This PR fixes the issue by using division / (1 << div) instead, which truncates result towards zero.

@Yowkees
Yowkees requested a review from koron December 11, 2023 02:49
@koron

koron commented Mar 21, 2024

Copy link
Copy Markdown
Collaborator

Thank you for your good point!

The only thing I'm worried about is the size increase due to division.
I'll do some experimentation and then merge.

@koron

koron commented Mar 21, 2024

Copy link
Copy Markdown
Collaborator

I confirmed this increases 62 bytes.

Are there any good tricks to reduce this?

@koron

koron commented Mar 21, 2024

Copy link
Copy Markdown
Collaborator

I fix this to reduce size in #507

@koron
koron merged commit d4ff08c into Yowkees:main Mar 21, 2024
@koron

koron commented Mar 21, 2024

Copy link
Copy Markdown
Collaborator

I merged this with #507.

Thank you

@MiSawa

MiSawa commented Mar 21, 2024

Copy link
Copy Markdown
Contributor Author

Thank YOU!

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