Added full screen toggle via ENTER or TAP/CLICK
Signed-off-by: James Ketrenos <james_gitlab@ketrenos.com>
This commit is contained in:
parent
8c7a9dbcf4
commit
0dbf380286
@ -157,7 +157,19 @@ function schedule() {
|
|||||||
tick();
|
tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
var paused = false;
|
function toggleFullscreen() {
|
||||||
|
if (!document.fullscreenElement) {
|
||||||
|
document.documentElement.requestFullscreen();
|
||||||
|
} else {
|
||||||
|
if (document.exitFullscreen) {
|
||||||
|
document.exitFullscreen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var paused = false,
|
||||||
|
tap = 0;
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
var tmp = document.querySelector("base");
|
var tmp = document.querySelector("base");
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
@ -166,8 +178,20 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
base = "/";
|
base = "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.addEventListener("click", function(event) {
|
||||||
|
toggleFullscreen();
|
||||||
|
var now = new Date().getTime();
|
||||||
|
if (tap && (now - tap < 300)) {
|
||||||
|
toggleFullscreen();
|
||||||
|
tap = 0;
|
||||||
|
} else {
|
||||||
|
tap = new Date().getTime();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
document.addEventListener("keydown", function(event) {
|
document.addEventListener("keydown", function(event) {
|
||||||
if (event.keyCode == 32) { /* space */
|
switch (event.keyCode) {
|
||||||
|
case 32: /* space */
|
||||||
paused = !paused;
|
paused = !paused;
|
||||||
if (!paused) {
|
if (!paused) {
|
||||||
tick();
|
tick();
|
||||||
@ -177,21 +201,23 @@ document.addEventListener("DOMContentLoaded", function() {
|
|||||||
scheduled = null;
|
scheduled = null;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (event.keyCode == 37) { /* left */
|
case 37: /* left */
|
||||||
if (photoIndex == 0) {
|
if (photoIndex == 0) {
|
||||||
photoIndex = photos.length;
|
photoIndex = photos.length;
|
||||||
}
|
}
|
||||||
photoIndex--;
|
photoIndex--;
|
||||||
loadPhoto(photoIndex);
|
loadPhoto(photoIndex);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (event.keyCode == 39) { /* right */
|
case 39: /* right */
|
||||||
photoIndex = (photoIndex + 1) % photos.length;
|
photoIndex = (photoIndex + 1) % photos.length;
|
||||||
loadPhoto(photoIndex);
|
loadPhoto(photoIndex);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case 13: /* enter */
|
||||||
|
toggleFullscreen();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(event.keyCode);
|
console.log(event.keyCode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user