tumpio / gmscripts

tumpio's usercripts
https://openuserjs.org/users/tumpio
MIT License
61 stars 28 forks source link

Provide relative-scrolling and middle-start options; fixes #21

Closed joeytwiddle closed 5 years ago

joeytwiddle commented 5 years ago

Motivation: When I start to drag, the page suddenly jumps to a new position. This can cause me to lose my place, especially if I just wanted to scroll down a small amount (e.g. one page). So I would like the dragging to start from the current page position.

Without changing the default behaviour of the script, this PR adds two different ways of doing that.


With middleStart = true the mouse coordinates where dragging started will match the page's scroll position when dragging started. This is done by scaling the drag regions above and below the start coordinates differently.

This keeps the ability to scroll the entire page in one drag, which is one of ScrollEverywhere's nice features.


Alternatively, if you set relativeScrolling = true then moving the mouse will scroll the page relative to its current scroll position, at a rate relative to the mouse movement speed.

With reverse = true this feels like scrolling on a mobile phone or a tablet, where you "push" the page with your fingers. (I have also added some velocity, so you can get faster scrolling from faster mouse movement.)

Unfortunately this method does not retain the ability to scroll the entire page in one drag, at least not so intuitively.


It occurs to me now that when using ScrollEverywhere with its default settings, the trick is to look at the scrollbar widget, and start your mouse-drag from the top/middle of the widget. That avoids the jumping affect from happening!

This hadn't occurred to me when I started using ScrollEverywhere. (I was expecting to scroll relative to the page's current position.) Perhaps the suggestion could be made clear in the documentation, to assist user onboarding.


The fixes for scrollTop, scrollWidth and scrollHeight help the script to work on more sites (e.g. YouTube). Not sure why we sometimes need to read the value from different places.

tumpio commented 5 years ago

@joeytwiddle Looks good! 👍

You might want to check this add-on aswell: https://addons.mozilla.org/firefox/addon/scroll_anywhere/