diff options
author | elioat <elioat@tilde.institute> | 2024-01-12 22:18:33 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-01-12 22:18:33 -0500 |
commit | 215e4fe52d774461cc17eb5508eb33a39c7303f6 (patch) | |
tree | 0bf41a3b2e2cc21f69b7b294440d5ad85f57e0b2 /js/inknswitch | |
parent | 7d678797e20d6897c8a287c91d99864dd8c84e0b (diff) | |
download | tour-215e4fe52d774461cc17eb5508eb33a39c7303f6.tar.gz |
*
Diffstat (limited to 'js/inknswitch')
-rw-r--r-- | js/inknswitch/ink.js | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/js/inknswitch/ink.js b/js/inknswitch/ink.js index cd0c540..73f16e5 100644 --- a/js/inknswitch/ink.js +++ b/js/inknswitch/ink.js @@ -160,21 +160,20 @@ document.addEventListener('keydown', (e) => { localStorage.setItem('noteContent', noteArea.value); }); -let touchStartTimestamp; -let touchStartCount; - -document.addEventListener('touchstart', function(e) { - touchStartTimestamp = Date.now(); - touchStartCount = e.touches.length; - 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 +let lastTap = 0; +let tapCount = 0; + +document.addEventListener('touchend', function(e) { + const currentTime = Date.now(); + const tapInterval = currentTime - lastTap; + if (tapInterval < 500 && tapInterval > 0) { + tapCount++; + if (tapCount === 3) { toggleMode(); + tapCount = 0; } + } else { + tapCount = 1; } + lastTap = currentTime; }, false); \ No newline at end of file |