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