Skip to content

Commit

Permalink
Make VirtualStick value go back to zero when letting go
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchirls committed Jul 30, 2022
1 parent fd22919 commit 800834e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/devices/virtualstick.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,23 @@ export default class VirtualStick extends Device {
}
};

function pointerUp(evt: PointerEvent) {
const pointerUp = (evt: PointerEvent) => {
if (startEvent && startEvent.pointerId === evt.pointerId) {
lastEvent = evt;
startEvent = null;

/*
Revert back to zero when we let go. Ideally, this would fall linearly
over time, but that's complicated. It would require an update in the
animation loop and a configuration value for falloff rate.
*/
if (deltaX || deltaY) {
deltaX = 0;
deltaY = 0;
this.emit('change');
}
}
}
};

const styleElement = touchActionStyle && element.style ? element : document.body;

Expand Down

0 comments on commit 800834e

Please sign in to comment.