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;