Commit cdcaac89 authored by Fred Chasen's avatar Fred Chasen

Add arrows

parent 787ef7b0
......@@ -89,6 +89,16 @@ class Reader {
this.resizer();
});
let page = 0;
this.chunker.on("page", () => {
page++;
if (page === 2) {
this.arrows(this.scale);
}
});
window.addEventListener("resize", this.resizer.bind(this), false);
await this.addStyles(this.manifest.stylesheets);
......@@ -112,6 +122,8 @@ class Reader {
pages.style.marginLeft = "0";
}
this.scale = scale;
}
addStyles(stylesArray) {
......@@ -129,6 +141,42 @@ class Reader {
}
}
arrows(scale) {
let page = document.querySelector(".pagedjs_page");
let height = (page.offsetHeight + 51) * scale;
var next = document.getElementById("next");
next.style.visibility = "visible";
next.addEventListener("click", function(e){
window.scrollBy(0, height);
e.preventDefault();
}, false);
var prev = document.getElementById("prev");
prev.style.visibility = "visible";
prev.addEventListener("click", function(e){
window.scrollBy(0, -height);
e.preventDefault();
}, false);
var keyListener = function(e){
// Left Key
if ((e.keyCode || e.which) == 37) {
window.scrollBy(0, -height);
}
// Right Key
if ((e.keyCode || e.which) == 39) {
window.scrollBy(0, height);
}
};
document.addEventListener("keyup", keyListener, false);
}
destroy() {
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment