manga mode

This commit is contained in:
Bala Clark 2010-07-10 13:21:09 +01:00
parent 2df9b56d56
commit 4a2c42fa02

View file

@ -6,7 +6,6 @@
- Show a progress bar when buffering
- use document.body.offsetWidth where present? (instead of window.innerWidth, the former excludes the width of scrollbars)
- scroll two pages at a time in double page mode
- manga mode
- page controls
- thumbnail browser
- chrome frame
@ -49,7 +48,8 @@ function ComicBook(id, srcs, opts) {
var defaults = {
displayMode: "double", // single / double
zoomMode: "fitWidth" // manual / fitWidth
zoomMode: "fitWidth", // manual / fitWidth
manga: false
};
var options = merge(defaults, opts); // options array for internal use
@ -226,10 +226,17 @@ function ComicBook(id, srcs, opts) {
offsetH = (window.innerHeight - page_height) / 2;
}
// in manga double page mode reverse the pages
if (options.manga && options.displayMode === "double") {
var tmpPage = page;
var tmpPage2 = page2; // FIXME: check this exists before using
page = tmpPage2;
page2 = tmpPage;
}
// draw the page(s)
context.drawImage(page, offsetW, offsetH, page_width, page_height);
if (options.displayMode === "double" && typeof page2 === "object") { context.drawImage(page2, page_width + offsetW, offsetH, page_width, page_height); }
};
/**
@ -260,11 +267,19 @@ function ComicBook(id, srcs, opts) {
if (e.type === "click") {
var side = getCursorPosition(e);
window.scroll(0,0);
switch (getCursorPosition(e)) {
case "left": ComicBook.prototype.drawPrevPage(); break;
case "right": ComicBook.prototype.drawNextPage(); break;
// western style (left to right)
if (!options.manga) {
if (side === "left") { ComicBook.prototype.drawPrevPage(); }
if (side === "right") { ComicBook.prototype.drawNextPage(); }
}
// manga style (right to left)
else {
if (side === "left") { ComicBook.prototype.drawNextPage(); }
if (side === "right") { ComicBook.prototype.drawPrevPage(); }
}
}
};
@ -286,7 +301,8 @@ window.onload = function() {
var options = {
displayMode: "double",
zoomMode: "fitWidth"
zoomMode: "fitWidth",
manga: false
};
book = new ComicBook("comic", pages, options);