Skip to content

Normalize pixel-mode wheel events to correct scroll distance scaling on Web. - #3262

Open
Konstantin (terrakok) wants to merge 3 commits into
jb-mainfrom
CMP-10524
Open

Normalize pixel-mode wheel events to correct scroll distance scaling on Web.#3262
Konstantin (terrakok) wants to merge 3 commits into
jb-mainfrom
CMP-10524

Conversation

@terrakok

Copy link
Copy Markdown
Member

Fixes https://youtrack.jetbrains.com/issue/CMP-10524

Release Notes

Fixes - Web

  • Normalize scroll delta scaling on Web.

* on the same ~1-per-notch scale as other targets.
*/
@InternalComposeUiApi
const val WebWheelDeltaPerNotch = 120.0

@igordmn Igor Demin (igordmn) Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you have 120 on one tick in https://jsfiddle.net/64p5r459/2/?

Can you describe on which OS with which device you tested?

I have 100 on Windows + real mouse, 4 with acceleration on macOs + real mouse

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also I noticed if you change the page scale, the value changes

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The system scale doesn't affect it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

120 is a constant for a "standard wheel click"
https://learn.microsoft.com/en-us/windows/win32/inputdev/wm-mousewheel

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it shouldn't be exactly 120. this is the divider

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I found a good enough value which works well on my macos. Could you check it on your windows?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(added a demo case for that)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I checked, it doesn't work good on Windows, one tick is 10.0, but it should be 1.0. I.e. we should divide by 100, not by 10.

As a note, mouse wheel doesn't work good on macOs in native apps too. What do you mean by works well?

@igordmn Igor Demin (igordmn) Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

As a note, mouse wheel doesn't work good on macOs in native apps too. What do you mean by works well?

The first tick on macOs is 0.1 on my macOs machine on Desktop. As I wrote in the issue, we considered this "by design" as an macOs quirk for a wheel. It accelerates to greater values if you scroll fast.

The main issue is that it is 0.04 on Web if we divide by 100. I am not sure why is it different from Swing. We probably should understand that to reason about it objectively (by reading Chromium/JDK sources)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The delta adjusted to be good on every platform. We manually checked it on every platform and it seems OK

* on the same ~1-per-notch scale as other targets.
*/
@InternalComposeUiApi
const val WebWheelDeltaPerNotch = 120.0

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I checked, it doesn't work good on Windows, one tick is 10.0, but it should be 1.0. I.e. we should divide by 100, not by 10.

As a note, mouse wheel doesn't work good on macOs in native apps too. What do you mean by works well?

@igordmn Igor Demin (igordmn) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's not merge until we resolve the comment

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.

3 participants