Skip to content

Commit

Permalink
fix dragging when panning with touch
Browse files Browse the repository at this point in the history
  • Loading branch information
espmaniac authored Nov 28, 2024
1 parent 52e52ba commit fe8db5e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,12 @@ canvas.addEventListener("touchmove", function(event) {
let pointerX = event.touches[0].clientX - canvas.getBoundingClientRect().left;
let pointerY = event.touches[0].clientY - canvas.getBoundingClientRect().top;

if (touches.length !== event.touches.length) {
panOffX = pointerX;
panOffY = pointerY;

}

if (event.touches.length <= 1) {

if (isDragging) {
Expand All @@ -792,9 +798,6 @@ canvas.addEventListener("touchmove", function(event) {
else if (isPanning) {
offsetX -= (panOffX - pointerX) / zoom;
offsetY -= (panOffY - pointerY) / zoom;

panOffX = pointerX;
panOffY = pointerY;
}

}
Expand Down Expand Up @@ -835,9 +838,15 @@ canvas.addEventListener("touchmove", function(event) {
offsetX += current.x - prev.x;
offsetY += current.y - prev.y;




}


panOffX = pointerX;
panOffY = pointerY;

touches = event.touches;


Expand Down

0 comments on commit fe8db5e

Please sign in to comment.