minor preload tweak, removed useless parameter
This commit is contained in:
parent
e4edf4e80f
commit
d7e7450912
1 changed files with 18 additions and 15 deletions
|
@ -12,6 +12,7 @@
|
|||
- really need to speed up enhancements, try to use webworkers
|
||||
|
||||
Nice 2 have:
|
||||
- smart preload, start 5 before pointer and load from there, on navigation update preload position
|
||||
- offline access
|
||||
- thumbnail browser
|
||||
- page turn animation? (http://www.cynergysystems.com/blogs/page/rickbarraza?entry=the_secret_behind_the_page)
|
||||
|
@ -60,11 +61,14 @@ function ComicBook(id, srcs, opts) {
|
|||
var context; // the 2d drawing context
|
||||
|
||||
var buffer = 4; // image preload buffer level
|
||||
var pointer = 0; // the current page
|
||||
|
||||
var loaded = 0; // the amount of images that have been loaded so far
|
||||
|
||||
var scale = 1; // page zoom scale, 1 = 100%
|
||||
|
||||
// the current page, can pass a default as a url hash
|
||||
var pointer = (parseInt(window.location.hash.replace('#',''),10) - 1) || 0;
|
||||
|
||||
/**
|
||||
* Figure out the cursor position relative to the canvas.
|
||||
*
|
||||
|
@ -95,7 +99,6 @@ function ComicBook(id, srcs, opts) {
|
|||
* @see #ComicBook.prototype.enhance
|
||||
*/
|
||||
function init() {
|
||||
|
||||
// setup canvas
|
||||
canvas = document.getElementById(canvas_id);
|
||||
context = canvas.getContext("2d");
|
||||
|
@ -105,8 +108,6 @@ function ComicBook(id, srcs, opts) {
|
|||
}
|
||||
|
||||
/*
|
||||
* @param {String} id The canvas ID to draw the comic on.
|
||||
* @param {Object} srcs An array of all the comic page srcs, in order
|
||||
* @see #preload
|
||||
*/
|
||||
ComicBook.prototype.draw = function () {
|
||||
|
@ -114,7 +115,7 @@ function ComicBook(id, srcs, opts) {
|
|||
init();
|
||||
|
||||
// preload images if needed
|
||||
if (pages.length !== no_pages) { this.preload(this.srcs); }
|
||||
if (pages.length !== no_pages) { this.preload(); }
|
||||
else { this.drawPage(); }
|
||||
};
|
||||
|
||||
|
@ -132,10 +133,11 @@ function ComicBook(id, srcs, opts) {
|
|||
/**
|
||||
* Preload all images, draw the page only after a given number have been loaded.
|
||||
*
|
||||
* @param srcs {Object} srcs
|
||||
* @see #drawPage
|
||||
*/
|
||||
ComicBook.prototype.preload = function (srcs) {
|
||||
ComicBook.prototype.preload = function () {
|
||||
|
||||
var srcs = this.srcs;
|
||||
|
||||
if (no_pages < buffer) { buffer = no_pages; } // don't get stuck if the buffer level is higher than the number of pages
|
||||
|
||||
|
@ -189,7 +191,6 @@ function ComicBook(id, srcs, opts) {
|
|||
|
||||
var zoom_scale;
|
||||
var offsetW = 0, offsetH = 0;
|
||||
|
||||
var page = pages[pointer];
|
||||
var page2 = pages[pointer + 1];
|
||||
|
||||
|
@ -266,6 +267,8 @@ function ComicBook(id, srcs, opts) {
|
|||
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); }
|
||||
|
||||
window.location.hash = pointer + 1;
|
||||
|
||||
// apply any image enhancements previously defined
|
||||
$.each(options.enhance, function(action, options) {
|
||||
ComicBook.prototype.enhance[action](options);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue