more hacky pointer bugfixes
This commit is contained in:
parent
280fe124b2
commit
e1d267b38b
1 changed files with 16 additions and 8 deletions
|
@ -93,12 +93,6 @@ function ComicBook(id, srcs, opts) {
|
|||
var page_requested = false; // used to request non preloaded pages
|
||||
var shiv = false;
|
||||
|
||||
// page hash on first load
|
||||
var hash = parseInt(location.hash.substring(1),10) - 1;
|
||||
|
||||
// the current page, can pass a default as a url hash
|
||||
var pointer = (hash < srcs.length) ? hash : 0;
|
||||
|
||||
/**
|
||||
* Gets the window.innerWidth - scrollbars
|
||||
*/
|
||||
|
@ -138,13 +132,24 @@ function ComicBook(id, srcs, opts) {
|
|||
}
|
||||
|
||||
function getHash() {
|
||||
return parseInt(location.hash.substring(1),10) - 1 || 0;
|
||||
var hash = parseInt(location.hash.substring(1),10) - 1 || 0;
|
||||
if (hash < 0) {
|
||||
setHash(0);
|
||||
hash = 0;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
function setHash(pageNo) {
|
||||
location.hash = pageNo;
|
||||
}
|
||||
|
||||
// page hash on first load
|
||||
var hash = getHash();
|
||||
|
||||
// the current page, can pass a default as a url hash
|
||||
var pointer = (hash < srcs.length) ? hash : 0;
|
||||
|
||||
/**
|
||||
* Setup the canvas element for use throughout the class.
|
||||
*
|
||||
|
@ -509,7 +514,7 @@ function ComicBook(id, srcs, opts) {
|
|||
ComicBook.prototype.drawPage = function(page_no) {
|
||||
|
||||
// if a specific page is given try to render it, if not bail and wait for preload() to render it
|
||||
if (typeof page_no === "number" && page_no < srcs.length) {
|
||||
if (typeof page_no === "number" && page_no < srcs.length && page_no > 0) {
|
||||
pointer = page_no-1;
|
||||
if (!this.pageLoaded(page_no)) {
|
||||
this.showControl("loadingOverlay");
|
||||
|
@ -517,6 +522,8 @@ function ComicBook(id, srcs, opts) {
|
|||
}
|
||||
}
|
||||
|
||||
if (pointer < 0) { pointer = 0; }
|
||||
|
||||
var zoom_scale;
|
||||
var offsetW = 0, offsetH = 0;
|
||||
|
||||
|
@ -692,6 +699,7 @@ function ComicBook(id, srcs, opts) {
|
|||
is_double_page_spread = (page.width > page.height); // need to run double page check again here as we are going backwards
|
||||
|
||||
if (pointer > 0) {
|
||||
console.log(pointer);
|
||||
pointer -= (options.displayMode === "single" || is_double_page_spread) ? 1 : 2;
|
||||
this.drawPage();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue