Skip to content

Commit

Permalink
[twisty] Apply the Firefox timestamp collision workaround to the old …
Browse files Browse the repository at this point in the history
…orbit controls.
  • Loading branch information
lgarron committed Sep 2, 2021
1 parent ccb6673 commit 43190d8
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/cubing/twisty/dom/viewers/TwistyOrbitControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,13 @@ export class TwistyOrbitControls {
);
this.onMove(movementX, movementY);

this.lastMouseMoveMomentumX =
movementX / (e.timeStamp - this.lastMouseTimestamp);
this.lastMouseMoveMomentumY =
movementY / (e.timeStamp - this.lastMouseTimestamp);
this.lastMouseTimestamp = e.timeStamp;
if (e.timeStamp !== this.lastTouchTimestamp) {
this.lastMouseMoveMomentumX =
movementX / (e.timeStamp - this.lastMouseTimestamp);
this.lastMouseMoveMomentumY =
movementY / (e.timeStamp - this.lastMouseTimestamp);
this.lastMouseTimestamp = e.timeStamp;
}
}

onMouseEnd(e: MouseEvent): void {
Expand Down Expand Up @@ -280,11 +282,13 @@ export class TwistyOrbitControls {
this.lastTouchClientX = touch.clientX;
this.lastTouchClientY = touch.clientY;

this.lastTouchMoveMomentumX =
movementX / (e.timeStamp - this.lastTouchTimestamp);
this.lastTouchMoveMomentumY =
movementY / (e.timeStamp - this.lastTouchTimestamp);
this.lastTouchTimestamp = e.timeStamp;
if (e.timeStamp !== this.lastTouchTimestamp) {
this.lastTouchMoveMomentumX =
movementX / (e.timeStamp - this.lastTouchTimestamp);
this.lastTouchMoveMomentumY =
movementY / (e.timeStamp - this.lastTouchTimestamp);
this.lastTouchTimestamp = e.timeStamp;
}
}
}
}
Expand Down

0 comments on commit 43190d8

Please sign in to comment.