gdh1995 / vimium-c

A keyboard shortcut browser extension for keyboard-based navigation and tab operations with an advanced omnibar
https://chrome.google.com/webstore/detail/vimium-c/hfjbmagddngcpeloejdejnfgbamkjaeg
Other
3.46k stars 253 forks source link

Add smooth scroll easing #1093

Open fishstik opened 9 months ago

fishstik commented 9 months ago

Would be great to add some easing to the smooth scroll to make it visually smoother, like in chromium-vim:

chromium-vim scrollPageDown/Up vimium scrollPageDown/Up

chromium-vim scrollToTop/Bottom vimium scrollToTop/Bottom

chromium-vim's implementation: https://github.com/1995eaton/chromium-vim/blob/60567d650c430e46ee894f8ea6b224bc48805aa5/content_scripts/scroll.js#L96-L98

I am guessing this delta calculation can be changed to implement this: https://github.com/gdh1995/vimium-c/blob/d470de4159e1d8ec16f2683484927534c1ba0b1b/content/scroller.ts#L165-L168

shynekomaid commented 9 months ago

Interesting, but it must be as option. And need smooth when spam j or k. (Fast image draft below) image

gdh1995 commented 9 months ago

Um, now the scrolling has been somehow "smooth".

Some years ago Vimium C used a same strategy to scroll smoothly just like Vimium, but the code worked badly on a screen of > 60 fps. So I modified the code for many times and finally created such a mess...

However the keypoint feature is always kept - it computes a target speed and gets nearer and nearer to the speed when you hold on a key, whether or not the target speed is faster or slower than a first speed.

If you think Vimium C scrools too slow on scrollPageDown, you may use "count prefix" to obviously increase the target speed - for example, 3j is much faster than a plain j.

gdh1995 commented 9 months ago

Basically I'm satisfied with the current "smooth scrolling" logic, because I think:

  1. constant speed is good, at least in the beginning phase, like a short keydown and keyup
  2. when I hold on a key to continue to scroll, I prefer to glance over scrolled content
      1. so it should not scroll too fast, otherwise it will prevent me from reading page content
      1. If I do want to scroll down/up very fast (and avoid using commands like scrollToBottom), I may type "count prefix" to achieve this effect

Therefore, I may not implement such a "steep" ease-in/out effect.

shynekomaid commented 8 months ago

Ok, I think scrolling is good. @fishstik, you can close issue.