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

fixed hooks, min image size for pagination

This commit is contained in:
fchasen 2015-06-21 17:31:18 -04:00
parent 2a95b28041
commit a7d5c6f77a
7 changed files with 283 additions and 109 deletions

View file

@ -17,21 +17,31 @@ EPUBJS.Hook.prototype.register = function(func){
// Triggers a hook to run all functions
EPUBJS.Hook.prototype.trigger = function(){
var length = this.hooks.length;
var hooks = this.hooks;
var length = hooks.length;
var current = 0;
var executing;
var defer = new RSVP.defer();
var args = arguments;
var next = function(){
current += 1;
if(current < length) {
return hooks[current].apply(this.context, args);
}
}.bind(this);
if(length) {
executing = this.hooks[current].apply(this.context, args);
executing.then(function(){
current += 1;
if(current < length) {
return this.hooks[current].apply(this.context, args);
}
}.bind(this));
if(executing && typeof executing["then"] === "function") {
// Task is a function that returns a promise
executing.then(next);
} else {
// Task resolves immediately
next();
}
} else {
executing = defer.promise;