refactor
This commit is contained in:
parent
4d7d27c5a6
commit
35f4176375
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user