1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-03 14:59:18 +02:00

Move keyListener above first use of it. Render works.

This commit is contained in:
BoatrightTBC 2019-05-15 18:37:06 -05:00
parent 8eae0c252d
commit d22e4e5197

View file

@ -39,7 +39,7 @@
var next = document.getElementById("next"); var next = document.getElementById("next");
var prev = document.getElementById("prev"); var prev = document.getElementById("prev");
book.open(bookData); book.open(bookData, "binary");
rendition = book.renderTo("viewer", { rendition = book.renderTo("viewer", {
width: "100%", width: "100%",
@ -48,6 +48,20 @@
rendition.display(); rendition.display();
var keyListener = function(e){
// Left Key
if ((e.keyCode || e.which) == 37) {
rendition.prev();
}
// Right Key
if ((e.keyCode || e.which) == 39) {
rendition.next();
}
};
rendition.on("keyup", keyListener); rendition.on("keyup", keyListener);
rendition.on("relocated", function(location){ rendition.on("relocated", function(location){
console.log(location); console.log(location);
@ -63,19 +77,7 @@
e.preventDefault(); e.preventDefault();
}, false); }, false);
var keyListener = function(e){
// Left Key
if ((e.keyCode || e.which) == 37) {
rendition.prev();
}
// Right Key
if ((e.keyCode || e.which) == 39) {
rendition.next();
}
};
document.addEventListener("keyup", keyListener, false); document.addEventListener("keyup", keyListener, false);