From 02e6b30a1f17201f35bf5035bf7ef7d3d708ecd9 Mon Sep 17 00:00:00 2001 From: nebula Date: Wed, 2 Apr 2025 03:02:38 +0000 Subject: [PATCH] insert descriptive commit here --- js/imgGallery.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/imgGallery.js b/js/imgGallery.js index ecebf05..711afaf 100644 --- a/js/imgGallery.js +++ b/js/imgGallery.js @@ -5,11 +5,14 @@ galleryImage = document.getElementById("galleryImage"); previewLinks = document.getElementsByClassName("previewLink"); headerImage = document.getElementById("headerImage"); -touchDragStartX = null; touchDragThreshold = 50; -touchDirection = null; directionDetermined = false; +// null is used when no information is supposed to be available. +// functions set these to useful values during touch events. +touchDragStartX = null; +touchDirection = null; + function enlargeImage (filename) { viewState = photos.indexOf(filename); galleryImage.fullRes = filename; @@ -72,6 +75,7 @@ function mouseUpHandler (event) { }; function onTouchMove (event) { + event.preventDefault(); screenX = event.changedTouches[0].screenX; if (!directionDetermined && touchDragStartX == null) { touchDragStartX = screenX; @@ -85,6 +89,7 @@ function onTouchMove (event) { }; function onTouchEnd (event) { + event.preventDefault(); // poorly phrased, but this must reset state to default directionDetermined = false; touchDragStartX = null;