From cee1f9758ee7ef45b1c1fce65a69916e58fda6a2 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 28 Jun 2022 01:14:31 -0700 Subject: [PATCH] Update slide deck (#227) --- docs/deck/index.html | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/docs/deck/index.html b/docs/deck/index.html index 9a513d6907..3e85ce070f 100644 --- a/docs/deck/index.html +++ b/docs/deck/index.html @@ -10,28 +10,44 @@ let current = parseInt(window.location.hash.substring(1)) || 0; window.location.hash = current; document.addEventListener("keydown", function(event) { - let next = current; switch (event.key) { case " ": case "ArrowDown": case "ArrowRight": case "Enter": - next += 1; + slide(current + 1); break; case "ArrowLeft": case "ArrowUp": - next -= 1; + slide(current - 1); break; } + }); - if (next < 0 || next + 1 > SLIDES) { + function slide(i) { + if (i < 0 || i >= SLIDES) { return; } - window.location.hash = next; + window.location.hash = current = i; + } + + let x; - current = next; + document.addEventListener('touchstart', e => { + x = e.changedTouches[0].screenX; }); + + document.addEventListener('touchend', e => { + if (e.changedTouches[0].screenX < x) { + slide(current + 1); + } + + if (e.changedTouches[0].screenX > x) { + slide(current - 1); + } + }); +