This commit is contained in:
nebula 2025-04-02 02:54:23 +00:00
parent 4d7d27c5a6
commit 35f4176375

View File

@ -8,7 +8,7 @@ headerImage = document.getElementById("headerImage");
touchDragStartX = null; touchDragStartX = null;
touchDragThreshold = 50; touchDragThreshold = 50;
touchDirection = null; touchDirection = null;
touchLock = false; directionDetermined = false;
function enlargeImage (filename) { function enlargeImage (filename) {
viewState = photos.indexOf(filename); viewState = photos.indexOf(filename);
@ -73,19 +73,20 @@ function mouseUpHandler (event) {
function onTouchMove (event) { function onTouchMove (event) {
screenX = event.changedTouches[0].screenX; screenX = event.changedTouches[0].screenX;
if (!touchLock && touchDragStartX == null) { if (!directionDetermined && touchDragStartX == null) {
touchDragStartX = screenX; touchDragStartX = screenX;
}; };
touchDelta = Math.abs(touchDragStartX - screenX); touchDelta = Math.abs(touchDragStartX - screenX);
if (!touchLock && (touchDelta > touchDragThreshold)) { if (!directionDetermined && (touchDelta > touchDragThreshold)) {
touchDirection = touchDragStartX > screenX; touchDirection = touchDragStartX > screenX;
touchDragStartX = null; touchDragStartX = null;
touchLock = true; directionDetermined = true;
}; };
}; };
function onTouchEnd (event) { function onTouchEnd (event) {
touchLock = false; // poorly phrased, but this must reset state to default
directionDetermined = false;
touchDragStartX = null; touchDragStartX = null;
if (touchDirection == null) { if (touchDirection == null) {
return; return;