Skip to content

Commit

Permalink
Enable sliding pointer on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTrustyPwo committed Mar 8, 2024
1 parent 7b8aa9f commit e2d0b83
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions static/js/shared/pointer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function createPointer(pointer) {

["mousedown", "touchstart"].forEach(event => {
document.addEventListener(event, e => {
console.log(event);
for (let i = 0; i < pointers.length; i++) {
// use math check in triangle
// lazy to code
Expand All @@ -51,13 +52,18 @@ function createPointer(pointer) {
document.addEventListener(event, e => { dragging = -1; });
});

["mousemove", "touchmove"].forEach(event => {
document.addEventListener(event, e => {
if (dragging === -1) return;
const pointer = pointers[dragging];
pointer.y = Math.max(Math.min(pointer.y + e.movementY, pointer.maxY), pointer.minY);
pointer.onMove();
});
document.addEventListener("mousemove", e => {
if (dragging === -1) return;
const pointer = pointers[dragging];
pointer.y = Math.max(Math.min(pointer.y + e.movementY, pointer.maxY), pointer.minY);
pointer.onMove();
});

document.addEventListener("touchmove", e => {
if (dragging === -1) return;
const pointer = pointers[dragging];
pointer.y = Math.max(Math.min(e.targetTouches[0].pageY, pointer.maxY), pointer.minY);
pointer.onMove();
});

export { Pointer, createPointer };

0 comments on commit e2d0b83

Please sign in to comment.