-
-
Notifications
You must be signed in to change notification settings - Fork 149
fix(tab_row): simplify logic to ensure similar behavior between horiz… #2088
Conversation
…ontal/vertical scrolling (esp. noteworthy with touchpads)
if (!event.shiftKey && event.deltaX === 0)and incorporating deltaX += Math.sign(event.deltaY) * Math.max(Math.min(Math.abs(event.deltaY), TAB_CONTAINER_MIN_WIDTH * 3), TAB_CONTAINER_MIN_WIDTH);The reason is that your implementation lacks a smooth scrolling transition. As a result, when users scroll, a tab can instantly jump to a different position, which feels quite abrupt. For example, if I keep my eyes on a specific tab and scroll, it's difficult to tell how far the tab has moved, and visually tracking it becomes nearly impossible.
|
|
I found a method to check whether smooth scrolling is enabled on the user's computer: function quickSmoothScrollCheck() {
const cssSmooth = getComputedStyle(document.documentElement).scrollBehavior === 'smooth' ||
getComputedStyle(document.body).scrollBehavior === 'smooth';
const reducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
const browserSupport = 'scrollBehavior' in document.documentElement.style;
return cssSmooth && browserSupport && !reducedMotion;
}Based on this, if smooth scrolling is enabled, we can apply the original decelerated scrolling behavior. Otherwise, we can complete the scroll instantly. Additionally, I’ll make sure to include horizontal scrolling to maintain consistency. Please let me know if you'd like me to implement this. |
Interesting, how does that work in Electron? Would we need to add a setting for that? (related: TriliumNext/Trilium#5413) |
This is supported in Electron. It automatically enables or disables animations based on the system preference. On Windows, animations can be disabled in the advanced system settings, but Linux might not offer such an option. Therefore, if you want to support this feature, you could consider adding an option for it. The option could have three settings: auto, off, and on. |
Just had a look, there is a setting for it in Gnome Tweaks. So I don't think we need to add an option, but I guess we should check for |
|
Closing in favor of #2177. |
please could we not? #2177 causes more problem than it solves for me. As a minimum:
|
event.stopImmediatePropagation(); does not block hover events. To prevent hover effects during scrolling, hover handling needs to be disabled during the scroll. This mechanism can be added.
On the computer, only the vertical scroll amount can be set. Setting a large vertical scroll delta may cause the tabs to move too far. Limiting the scroll movement to a maximum width equivalent to 2 tabs seems reasonable — for example, VSCode uses even less, about one-third of a tab’s width, and this cannot be changed. Of course, removing this limit is also feasible; the choice depends on the trade-offs to be made. |
…ontal/vertical scrolling (esp. noteworthy with touchpads)