Skip to content

Quickly reverse direction when smooth scrolling#139

Merged
WillyJL merged 1 commit intoWillyJL:mainfrom
harikattar:scroll-fixes
May 9, 2024
Merged

Quickly reverse direction when smooth scrolling#139
WillyJL merged 1 commit intoWillyJL:mainfrom
harikattar:scroll-fixes

Conversation

@harikattar
Copy link
Copy Markdown
Contributor

First affects everybody: if you're at the top or bottom of the page, it will keep imparting scroll energy that takes time to expend. This makes the UI feel laggy and unresponsive if you've spun the scrollwheel to the top or bottom and want to start moving the other direction and it's still trying to scroll past the page.

Second affects people with enough games that they have pages of scroll. If you've scrolled to the game you're looking for it will keep coasting on past, and attempting to scroll back up doesn't work until you've imparted enough energy in the opposite direction. This can lead to overshoot.

@FaceCrap
Copy link
Copy Markdown
Contributor

FaceCrap commented Mar 24, 2024

Forgive me if I see this wrong, but if you only test if scroll_energy * imgui.io.mouse_wheel produces a negative result, than you don't actually detect a change in scroll direction.
You're only detecting scroll movements in that particular direction, regardless whether the previous direction was the same.

You're assuming here that the previous direction gave a positive result in that calculation.

Effectively, what you're doing here is dampening the direction that produces a negative result.
Because if you are already scrolling in that direction, your scroll_energy gets reset to 0.0 instead of allowing it to build up.

@harikattar
Copy link
Copy Markdown
Contributor Author

Forgive me if I see this wrong, but if you only test if scroll_energy * imgui.io.mouse_wheel produces a negative result, than you don't actually detect a change in scroll direction. You're only detecting scroll movements in that particular direction, regardless whether the previous direction was the same.

You're assuming here that the previous direction gave a positive result in that calculation.

Effectively, what you're doing here is dampening the direction that produces a negative result. Because if you are already scrolling in that direction, your scroll_energy gets reset to 0.0 instead of allowing it to build up.

No, it works like this:
-1 * -1 = 1
1 * -1 = -1
1 * 1 = 1
-1 * 1 = -1

the value is only negative if the signs are opposite - your input is the opposite of the scroll energy. Try it for yourself.

@WillyJL
Copy link
Copy Markdown
Owner

WillyJL commented May 9, 2024

indeed feels better, i never noticed it because i dont have a huge smoothing amount active (8, lower smoothens more) and so it would invert direction rather quickly. but with more smoothing, this is a night and day difference

@WillyJL WillyJL merged commit f1fb0fb into WillyJL:main May 9, 2024
@WillyJL WillyJL added the bugfix Something isn't working label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Something isn't working

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants