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

Only scroll after long press #32

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

joeytwiddle
Copy link
Contributor

@joeytwiddle joeytwiddle commented Mar 10, 2022

Hey it's me again, with a new feature! No problem if you don't want to merge this. But I'm pleased with it, so I wanted to share.

I found right-click problematic on Linux due to the context menu, and middle-click problematic for security, because it kept pasting my clipboard into random websites!

So I thought of an alternative:

  • Enable scrolling on left-click, but before entering scroll mode, the user must left-click-and-hold for 500ms (a "long press").

I have not change this script's default behaviour. To try the new feature, set:

  • startAfterLongPress = true and
  • mouseBtn = 1

You can also try this feature, already enabled, in my fork: Scroll Everywhere [fork] by joeywwiddle - Greasy Fork

Additional:

  • I added a ripple animation to indicate to the user when the scroll mode has started. We also change the cursor icon, but there is a long-standing issue that on some areas of some websites the page's cursor appears to override ours.
  • With or without this feature, the clicks we make to invoke our scroller will also send click events to OTHER listeners on the page or in other userscripts. I tried to prevent these events from being passed as much as possible.
    Details: I added a little code to mute click events if we have just done some scrolling. (But at this time, mouseup events are not muted, and muting mousedown events is probably impossible, since we don't know at that time whether the mousedown is intended for our scroller or for something else.)
  • Added my code which partially prevent paste events when using middle-click on Linux.
  • Wow! I made it work for ANY scrollable element on the page, not only the page body. This required quite a few changes.
  • Test whether that last change has affected the default modes. So far I have only tested on my own settings.
  • Perhaps we should get it working in iframes now, if we can.
  • When clicking on a native element, mousemove events are not sent to the page listeners. This results in the feature erroneously detecting and animating a long-click. This is really just a cosmetic problem, because it doesn't actually scroll, because it isn't receiving mousemove events. I managed to prevent this happening for scrollbars, but still need to work on some other native widgets, such as drop-down menus.

Because this feature is intended for (but not limited to) the left mouse button, but that button is used for lots of other things, there may be some edge-cases to deal with.

Please leave me a couple of weeks to iron them all out...!

@joeytwiddle joeytwiddle force-pushed the long-press branch 2 times, most recently from ec0411b to 0a488ed Compare March 10, 2022 07:36
@joeytwiddle joeytwiddle force-pushed the long-press branch 4 times, most recently from f2e5d19 to a7fa5f4 Compare March 13, 2022 06:13
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.

1 participant