Last active
January 13, 2017 17:34
Star
You must be signed in to star a gist
the teensiest slide application in human history: try it at http://ruphus.com/slides.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>tiny slides</title> | |
</head> | |
<body> | |
<main> | |
<section> | |
1. each slide is a <section> under the <main> tag. hit the right arrow to proceed… | |
</section> | |
<section> | |
2. second slide (left arrow goes back) | |
</section> | |
<section> | |
third slide (right will wrap around). All Javascript, HTML, and CSS less than 100 lines! | |
</section> | |
</main> | |
<style> | |
* { | |
padding:0; | |
margin:0; | |
} | |
body, main { display:flex; } | |
body { | |
height:100vh; | |
} | |
main { | |
flex:1; | |
} | |
main > section { | |
display:none; | |
flex:1; | |
justify-content:center; | |
align-items:center; | |
} | |
main section:first-child { | |
display:flex; | |
} | |
</style> | |
<script> | |
let main = document.querySelector('main'); | |
let slide = document.querySelector('main > section'); | |
document.addEventListener('keyup', ev => { | |
if(ev.which == 39 ){ // RIGHT_ARROW | |
main.insertAdjacentElement('beforeend', main.firstElementChild); | |
slide = main.firstElementChild; | |
} else if(ev.which == 37){ // LEFT_ARROW | |
main.insertAdjacentElement('afterbegin', main.lastElementChild); | |
slide = main.firstElementChild; | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment