diff options
author | elioat <elioat@tilde.institute> | 2024-01-12 22:14:01 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-01-12 22:14:01 -0500 |
commit | 7d678797e20d6897c8a287c91d99864dd8c84e0b (patch) | |
tree | 2d73e5f7ee1b809d82337d5cf4bc43b6471232ef | |
parent | 5126d4ceccd89cbc78359c2f5c5e675c9af83e2e (diff) | |
download | tour-7d678797e20d6897c8a287c91d99864dd8c84e0b.tar.gz |
*
-rw-r--r-- | js/inknswitch/ink.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/js/inknswitch/ink.js b/js/inknswitch/ink.js index 3a48ce6..cd0c540 100644 --- a/js/inknswitch/ink.js +++ b/js/inknswitch/ink.js @@ -166,15 +166,15 @@ let touchStartCount; document.addEventListener('touchstart', function(e) { touchStartTimestamp = Date.now(); touchStartCount = e.touches.length; -}, false); - -document.addEventListener('touchend', function(e) { - const touchEndTimestamp = Date.now(); - const touchEndCount = e.touches.length; - - // Check if the touch event was a two-finger tap - if (touchStartCount === 2 && touchEndCount === 0 && touchEndTimestamp - touchStartTimestamp < 500) { - // Two-finger tap detected - toggleMode(); + if (touchStartCount === 2) { + // Check if the touches are on either side of the screen + const touch1 = e.touches[0]; + const touch2 = e.touches[1]; + const screenWidth = window.innerWidth; + if ((touch1.clientX < screenWidth / 2 && touch2.clientX > screenWidth / 2) || + (touch2.clientX < screenWidth / 2 && touch1.clientX > screenWidth / 2)) { + // The touches are on either side of the screen + toggleMode(); + } } }, false); \ No newline at end of file |