mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-02 14:49:16 +02:00
Move keyListener above first use of it. Render works.
This commit is contained in:
parent
8eae0c252d
commit
d22e4e5197
1 changed files with 16 additions and 14 deletions
|
@ -39,7 +39,7 @@
|
|||
var next = document.getElementById("next");
|
||||
var prev = document.getElementById("prev");
|
||||
|
||||
book.open(bookData);
|
||||
book.open(bookData, "binary");
|
||||
|
||||
rendition = book.renderTo("viewer", {
|
||||
width: "100%",
|
||||
|
@ -47,6 +47,20 @@
|
|||
});
|
||||
|
||||
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("relocated", function(location){
|
||||
|
@ -63,19 +77,7 @@
|
|||
e.preventDefault();
|
||||
}, 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue