-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslider-notes.html
58 lines (53 loc) · 1.61 KB
/
slider-notes.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<html>
<style>
body {
font-family: Helvetica, sans-serif;
font-size: 30px;
}
#slide-content {
margin: 30px;
}
pre {
font-size: 60%;
}
</style>
<script>
function onDocReady(fn) {
// see if DOM is already available
if (document.readyState === 'complete' || document.readyState === 'interactive') {
// call on next available tick
setTimeout(fn, 1);
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
function captureEvent(e) {
if (e.target.nodeName == "BODY") {
e.preventDefault();
}
}
function onKey(e) {
switch (e.code) {
case "ArrowLeft":
captureEvent(e);
return window.opener && window.opener.moveLeft();
case "ArrowRight":
captureEvent(e);
return window.opener && window.opener.moveRight();
default:
console.log(`code: ${e.code}`);
}
}
function render(html) {
// scroll to top of document
document.body.scrollTop = document.documentElement.scrollTop = 0;
// console.log(html);
document.body.innerHTML = html;
}
onDocReady(function() {
document.addEventListener('keydown', onKey); // keyup resulted in arrows still working
});
</script>
<body>
</body>
</html>