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

Scrolling is too fast #795

Closed
wch opened this issue Jun 14, 2022 · 5 comments
Closed

Scrolling is too fast #795

wch opened this issue Jun 14, 2022 · 5 comments
Labels
Bug resolved if issue is resolved, it will be open until merge with master

Comments

@wch
Copy link

wch commented Jun 14, 2022

Issue summary

Scrolling with the touchpad or a mouse wheel is too fast. This makes it difficult to scroll a specific part of the history. I'm using a Mac, and this happens with both the touchpad and with a mouse scroll wheel, in Chrome, Firefox, and Safari.

This can be tested by going to https://jcubic.github.io/jquery.terminal/, holding down Enter until there are enough lines of output that a scrollbar appears, and then scrolling. The minimum scrolling increment for me is about 2 whole lines. In "normal" web content with a similar font size, the minimum scrolling increment is about 0.1-0.2 lines.

I found that replacing this:

if (delta > 0) {
self.scroll(-40);
} else {
self.scroll(40);
}

with this:

    self.scroll(-delta);

results in natural-feeling scrolling behavior, with proper acceleration.

Is there a particular reason that scrolling code sets the scrolling increment to 40?

@wch wch added the Bug label Jun 14, 2022
@jcubic
Copy link
Owner

jcubic commented Jun 14, 2022

The value was picked by experimentation, or maybe I took that value from somewhere). I think it was matching windows or Linux behavior.

You can disable mousewheel controlling if you return true from the event:

$('body').terminal(function(command) {

}, {
    mousewheel: () => true
});

Mousewheel was mostly done for Less plugin that changes the way you scroll.

@wch
Copy link
Author

wch commented Jun 14, 2022

Hi, thanks for your quick response. Two things:

It would be great if changing the scrolling behavior to be more normal as simple as the code snippet you provided!

@jcubic
Copy link
Owner

jcubic commented Jun 14, 2022

DO you only have a TypeScript error or the code doesn't work at all? TS errors are like warnings they still generate the output code so you can test if it works. I will add typing for the mousewheel event.

@wch
Copy link
Author

wch commented Jun 14, 2022

I just tried it again: I have the TypeScript error, but the code does work as you said. I previously thought the code did not work, but I think I was editing the wrong copy of the file on my computer. Thank you!

Also, I suggest adding mousewheel to the API documentation so that others will see how to deal with the scrolling speed issue.

@jcubic
Copy link
Owner

jcubic commented Jun 14, 2022

Yes, not everything is properly documented. There are a lot of issues for writing the documentation.

I need to take some time just go through everything in the code and properly document it.

jcubic added a commit that referenced this issue Jun 14, 2022
@jcubic jcubic added the resolved if issue is resolved, it will be open until merge with master label Jun 14, 2022
@jcubic jcubic closed this as completed Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug resolved if issue is resolved, it will be open until merge with master
Projects
None yet
Development

No branches or pull requests

2 participants