1
0
Fork 0
mirror of https://github.com/futurepress/epub.js.git synced 2025-10-04 15:09:16 +02:00

Add render changes to queue, fix view bounds

This commit is contained in:
Fred Chasen 2015-05-17 23:14:18 -04:00
parent 19eeab40e3
commit 83650961f8
11 changed files with 805 additions and 745 deletions

View file

@ -6,14 +6,16 @@ EPUBJS.Queue = function(_context){
};
// Add an item to the queue
EPUBJS.Queue.prototype.enqueue = function(task, args, context) {
EPUBJS.Queue.prototype.enqueue = function() {
var deferred, promise;
var queued;
var task = [].shift.call(arguments);
var args = arguments
// Handle single args without context
if(args && !args.length) {
args = [args];
}
// if(args && !Array.isArray(args)) {
// args = [args];
// }
if(typeof task === "function"){
@ -23,7 +25,7 @@ EPUBJS.Queue.prototype.enqueue = function(task, args, context) {
queued = {
"task" : task,
"args" : args,
"context" : context,
//"context" : context,
"deferred" : deferred,
"promise" : promise
};
@ -51,8 +53,9 @@ EPUBJS.Queue.prototype.dequeue = function(){
task = inwait.task;
if(task){
// Task is a function that returns a promise
return task.apply(inwait.context || this.context, inwait.args).then(function(){
return task.apply(this.context, inwait.args).then(function(){
inwait.deferred.resolve.apply(inwait.context || this.context, arguments);
}.bind(this));
@ -97,7 +100,7 @@ EPUBJS.Queue.prototype.length = function(){
return this._q.length;
};
// Create a new tast from a callback
// Create a new task from a callback
EPUBJS.Task = function(task, args, context){
return function(){