don't keep redrawing the page after the current one has been loading

This commit is contained in:
Bala Clark 2011-09-07 08:47:58 +02:00
parent 752bf3b02f
commit 4e4d707b14

View file

@ -441,13 +441,13 @@ function ComicBook(id, srcs, opts) {
this.showControl("loadingOverlay"); this.showControl("loadingOverlay");
var i = pointer; // the current page counter for this method var i = pointer; // the current page counter for this method
var rendered = false;
// I am using recursion instead of a forEach loop so that the next image is // I am using recursion instead of a forEach loop so that the next image is
// only loaded when the previous one has completely finished // only loaded when the previous one has completely finished
function preload(i) { function preload(i) {
var page = new Image(); var page = new Image();
var padding;
$("#cb-status").text("loading page " + (i + 1) + " of " + no_pages); $("#cb-status").text("loading page " + (i + 1) + " of " + no_pages);
@ -473,8 +473,9 @@ function ComicBook(id, srcs, opts) {
var buffer = (options.displayMode === "double" && pointer < srcs.length-1) ? 1 : 0; var buffer = (options.displayMode === "double" && pointer < srcs.length-1) ? 1 : 0;
// start rendering the comic when the requested page is ready // start rendering the comic when the requested page is ready
if ($.inArray(pointer + buffer, loaded) !== -1 if (rendered === false
|| (typeof page_requested === "number" && $.inArray(page_requested + buffer, loaded)) && ($.inArray(pointer + buffer, loaded) !== -1
|| (typeof page_requested === "number" && $.inArray(page_requested + buffer, loaded) !== -1))
) { ) {
// if the user is waiting for a page to be loaded, render that one instead of the default pointer // if the user is waiting for a page to be loaded, render that one instead of the default pointer
if (typeof page_requested === "number") { if (typeof page_requested === "number") {
@ -484,6 +485,7 @@ function ComicBook(id, srcs, opts) {
ComicBook.prototype.drawPage(); ComicBook.prototype.drawPage();
ComicBook.prototype.hideControl("loadingOverlay"); ComicBook.prototype.hideControl("loadingOverlay");
rendered = true;
} }
if (loaded.length === no_pages) { ComicBook.prototype.hideControl("status") } if (loaded.length === no_pages) { ComicBook.prototype.hideControl("status") }
}; };