Skip to content

Commit

Permalink
Update slide deck (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jun 28, 2022
1 parent d4d6d5d commit cee1f97
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions docs/deck/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});

</script>
<style>
html {
Expand Down

0 comments on commit cee1f97

Please sign in to comment.