Skip to content

Commit

Permalink
Reverse up and down for touchpads when navigating threads
Browse files Browse the repository at this point in the history
For left click, to be precise.

Change-Id: I3d5eae502073a4b7ac96e287e84b66857dc5ffdd
  • Loading branch information
jwbth committed May 31, 2024
1 parent ceafde5 commit b435f8d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,15 @@ class Thread {
*
* @param {number} fromX
* @param {number} fromY
* @param {boolean} grab Grab mode - reverse up and down (on touchpads).
* @private
*/
enterNavMode(fromX, fromY) {
enterNavMode(fromX, fromY, grab = false) {
this.handleClickAreaUnhover();
this.constructor.navMode = this.navMode = true;
this.navFromY = fromY;
this.navFromX = fromX;
this.navGrab = grab;

$(document)
.on('mousemove.cd', this.documentMouseMoveHandler)
Expand All @@ -378,7 +381,7 @@ class Thread {

if (Math.abs(e.clientX - this.navFromX) >= 5 || Math.abs(e.clientY - this.navFromY) >= 5) {
$(document).off('mousemove.cd', this.documentMouseMoveHandler);
this.enterNavMode(this.navFromX, this.navFromY);
this.enterNavMode(this.navFromX, this.navFromY, true);
}
return;
}
Expand Down Expand Up @@ -418,6 +421,10 @@ class Thread {
getNavTarget(delta) {
const stepSize = 100;

if (this.navGrab) {
delta *= -1;
}

if (!this.navInitialDirection) {
if (-15 < delta && delta < 15) {
this.updateCursor(0);
Expand Down Expand Up @@ -488,6 +495,7 @@ class Thread {
delete this.navFromX;
delete this.navScrolledTo;
delete this.navInitialDirection;
delete this.navGrab;
$(document)
.off('mousemove.cd', this.documentMouseMoveHandler)
.off('mouseup.cd mousedown.cd', this.quitNavModeHandler);
Expand Down

0 comments on commit b435f8d

Please sign in to comment.