Skip to content

Commit

Permalink
Make timeline scrolling less sluggish
Browse files Browse the repository at this point in the history
Behavior on chatView.contentY seems to be the primary reason of
underscrolling (#711): any kind of animation in it either cancels or
"smoothens" (in case of SmoothAnimation) the previous unfinished one,
effectively dampening the reaction to subsequent wheel "clicks" coming
from touchpads and high-precision mice. This commit keeps the Behavior
disabled most of the time, allowing to mark individual self-contained
scrolling actions (sic - not response to individual input events) as
animated, e.g. when the user presses Ctrl-PageUp/PageDown or clicks
on the UI button to scroll to the last read event.

In line with that, scrollUp()/scrollDown() is only used for animated
scrolls (and one is finally implemented in terms of the other);
non-animated scrolls boil down to a change applied to contentY.

The conversion ratio between angleDelta.y and dy has also been adjusted
and bound to the actual line height.

Closes #711.
  • Loading branch information
KitsuneRal committed Jul 28, 2023
1 parent 28eef67 commit 441d275
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions client/qml/Timeline.qml
Original file line number Diff line number Diff line change
Expand Up @@ -398,22 +398,18 @@ Page {
}

function scrollUp(dy) {
if (contentHeight > height)
if (contentHeight > height && dy !== 0) {
animateNextScroll = true
contentY -= dy
}
}
function scrollDown(dy) {
if (contentHeight > height)
contentY += dy
}
function scrollDown(dy) { scrollUp(-dy) }

function onWheel(wheel) {
if (wheel.angleDelta.x === 0) {
var yDelta = wheel.angleDelta.y * 10 / 36

if (yDelta > 0)
scrollUp(yDelta)
else
scrollDown(-yDelta)
// NB: Scrolling up yields positive angleDelta.y
if (contentHeight > height && wheel.angleDelta.y !== 0)
contentY -= wheel.angleDelta.y * settings.lineSpacing / 40
wheel.accepted = true
} else {
wheel.accepted = false
Expand Down Expand Up @@ -479,17 +475,15 @@ Page {
FastNumberAnimation { property: "opacity"; to: 1 }
}

property bool animateNextScroll: false
Behavior on contentY {
enabled: settings.enable_animations && !chatView.moving
&& !cruisingAnimation.running
SmoothedAnimation {
enabled: settings.enable_animations && chatView.animateNextScroll
animation: FastNumberAnimation {
id: scrollAnimation
duration: settings.fast_animations_duration_ms / 3
maximumEasingTime: settings.fast_animations_duration_ms

onRunningChanged: {
if (!running)
chatView.saveViewport(false)
onStopped: {
chatView.animateNextScroll = false
chatView.saveViewport(false)
}
}}

Expand Down

0 comments on commit 441d275

Please sign in to comment.