Skip to content

Commit

Permalink
change input of setTargetTouches to event, debug log targetTouches)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerwyn committed Dec 8, 2024
1 parent 6c8751f commit 23ae8bf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion dist/universal-remote-card.min.js

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions src/classes/remote-touchpad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,29 +194,29 @@ export class RemoteTouchpad extends BaseRemoteElement {
this.toggleRipple();
}

setTargetTouches(targetTouches: TouchList) {
// if (!this.targetTouches) {
// this.targetTouches = Array.from(targetTouches ?? []);
// } else {
// for (const touch of targetTouches) {
// const i = this.targetTouches.findIndex(
// (t) => t.identifier == touch.identifier,
// );
// if (i >= 0) {
// this.targetTouches[i] = touch;
// } else {
// this.targetTouches.push(touch);
// }
// }
// }
this.targetTouches = Array.from(targetTouches ?? []);
setTargetTouches(e: TouchEvent) {
if (!this.targetTouches) {
this.targetTouches = Array.from(e.targetTouches ?? []);
} else {
for (const touch of e.targetTouches) {
const i = this.targetTouches.findIndex(
(t) => t.identifier == touch.identifier,
);
if (i >= 0) {
this.targetTouches[i] = touch;
} else {
this.targetTouches.push(touch);
}
}
}
console.log(this.targetTouches);
}

setInitialXY(e: TouchEvent | MouseEvent) {
if ('targetTouches' in e) {
let totalX = 0;
let totalY = 0;
this.setTargetTouches(e.targetTouches);
this.setTargetTouches(e);
for (const touch of this.targetTouches ?? []) {
totalX += touch.clientX;
totalY += touch.clientY;
Expand All @@ -233,7 +233,7 @@ export class RemoteTouchpad extends BaseRemoteElement {
let currentX: number = 0;
let currentY: number = 0;
if ('targetTouches' in e) {
this.setTargetTouches(e.targetTouches);
this.setTargetTouches(e);
for (const touch of this.targetTouches ?? []) {
currentX += touch.clientX;
currentY += touch.clientY;
Expand Down

0 comments on commit 23ae8bf

Please sign in to comment.