Skip to content

Commit

Permalink
use total delta x/y when determinig if mouse action should be fired, …
Browse files Browse the repository at this point in the history
…not most recent
  • Loading branch information
Nerwyn committed Dec 9, 2024
1 parent 07d6247 commit abd7db5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/universal-remote-card.min.js

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions src/classes/remote-touchpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ export class RemoteTouchpad extends BaseRemoteElement {

// Only consider significant enough movement
const sensitivity = 2;
const totalDeltaX = (this.currentX ?? 0) - this.initialX;
const totalDeltaY = (this.currentY ?? 0) - this.initialY;
if (
this.renderTemplate(
this.config[`${multiPrefix}mouse_action`]?.action ?? 'none',
Expand All @@ -171,9 +173,8 @@ export class RemoteTouchpad extends BaseRemoteElement {
// Mouse actions
if (
this.holdMove ||
Math.abs(
Math.abs(this.deltaX ?? 0) - Math.abs(this.deltaY ?? 0),
) > sensitivity
Math.abs(Math.abs(totalDeltaX) - Math.abs(totalDeltaY)) >
sensitivity
) {
if (this.fireMouseAction) {
clearTimeout(this.holdTimer);
Expand All @@ -195,8 +196,6 @@ export class RemoteTouchpad extends BaseRemoteElement {
}
}
} else {
const totalDeltaX = (this.currentX ?? 0) - this.initialX;
const totalDeltaY = (this.currentY ?? 0) - this.initialY;
if (
Math.abs(Math.abs(totalDeltaX) - Math.abs(totalDeltaY)) >
sensitivity
Expand Down

0 comments on commit abd7db5

Please sign in to comment.