manga mode
This commit is contained in:
parent
2df9b56d56
commit
4a2c42fa02
1 changed files with 24 additions and 8 deletions
30
scripts.js
30
scripts.js
|
@ -6,7 +6,6 @@
|
||||||
- Show a progress bar when buffering
|
- Show a progress bar when buffering
|
||||||
- use document.body.offsetWidth where present? (instead of window.innerWidth, the former excludes the width of scrollbars)
|
- 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
|
- scroll two pages at a time in double page mode
|
||||||
- manga mode
|
|
||||||
- page controls
|
- page controls
|
||||||
- thumbnail browser
|
- thumbnail browser
|
||||||
- chrome frame
|
- chrome frame
|
||||||
|
@ -49,7 +48,8 @@ function ComicBook(id, srcs, opts) {
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
displayMode: "double", // single / double
|
displayMode: "double", // single / double
|
||||||
zoomMode: "fitWidth" // manual / fitWidth
|
zoomMode: "fitWidth", // manual / fitWidth
|
||||||
|
manga: false
|
||||||
};
|
};
|
||||||
|
|
||||||
var options = merge(defaults, opts); // options array for internal use
|
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;
|
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)
|
// draw the page(s)
|
||||||
context.drawImage(page, offsetW, offsetH, page_width, page_height);
|
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); }
|
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") {
|
if (e.type === "click") {
|
||||||
|
|
||||||
|
var side = getCursorPosition(e);
|
||||||
|
|
||||||
window.scroll(0,0);
|
window.scroll(0,0);
|
||||||
|
|
||||||
switch (getCursorPosition(e)) {
|
// western style (left to right)
|
||||||
case "left": ComicBook.prototype.drawPrevPage(); break;
|
if (!options.manga) {
|
||||||
case "right": ComicBook.prototype.drawNextPage(); break;
|
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 = {
|
var options = {
|
||||||
displayMode: "double",
|
displayMode: "double",
|
||||||
zoomMode: "fitWidth"
|
zoomMode: "fitWidth",
|
||||||
|
manga: false
|
||||||
};
|
};
|
||||||
|
|
||||||
book = new ComicBook("comic", pages, options);
|
book = new ComicBook("comic", pages, options);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue