From 35f41763758b3ddd7b8f9ef71ef1001870ac96af Mon Sep 17 00:00:00 2001 From: nebula Date: Wed, 2 Apr 2025 02:54:23 +0000 Subject: [PATCH] refactor --- js/imgGallery.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/js/imgGallery.js b/js/imgGallery.js index cb13fd7..ecebf05 100644 --- a/js/imgGallery.js +++ b/js/imgGallery.js @@ -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;