mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
Added render queue
This commit is contained in:
parent
b1ebc754cd
commit
ee19c03287
6 changed files with 282 additions and 65 deletions
|
@ -36,6 +36,10 @@ EPUBJS.Rendition = function(book, options) {
|
|||
this.infinite.on("scroll", this.check.bind(this));
|
||||
}
|
||||
|
||||
this.q = new EPUBJS.Queue(this);
|
||||
|
||||
this.q.enqueue(this.book.opened);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -121,6 +125,9 @@ EPUBJS.Rendition.prototype.attachTo = function(_element){
|
|||
|
||||
// Trigger Attached
|
||||
|
||||
// Start processing queue
|
||||
this.q.run();
|
||||
|
||||
};
|
||||
|
||||
EPUBJS.Rendition.prototype.attachListeners = function(){
|
||||
|
@ -139,43 +146,49 @@ EPUBJS.Rendition.prototype.display = function(what){
|
|||
var displaying = new RSVP.defer();
|
||||
var displayed = displaying.promise;
|
||||
|
||||
|
||||
// Check for fragments
|
||||
if(typeof what === 'string') {
|
||||
what = what.split("#")[0];
|
||||
}
|
||||
|
||||
this.book.opened.then(function(){
|
||||
var section = this.book.spine.get(what);
|
||||
var view;
|
||||
this.q.enqueue(this.move, what);
|
||||
|
||||
|
||||
return displayed;
|
||||
};
|
||||
|
||||
EPUBJS.Rendition.prototype.move = function(what){
|
||||
var displaying = new RSVP.defer();
|
||||
var displayed = displaying.promise;
|
||||
|
||||
var section = this.book.spine.get(what);
|
||||
var view;
|
||||
|
||||
this.displaying = true;
|
||||
|
||||
if(section){
|
||||
view = new EPUBJS.View(section);
|
||||
// Clear views
|
||||
// this.clear();
|
||||
this.fill(view);
|
||||
// rendered = this.render(section);
|
||||
|
||||
// if(this.settings.infinite) {
|
||||
// rendered.then(function(){
|
||||
// return this.fill.call(this);
|
||||
// }.bind(this));
|
||||
// }
|
||||
this.check();
|
||||
|
||||
this.displaying = true;
|
||||
view.displayed.then(function(){
|
||||
this.trigger("displayed", section);
|
||||
this.displaying = false;
|
||||
displaying.resolve(this);
|
||||
}.bind(this));
|
||||
|
||||
if(section){
|
||||
view = new EPUBJS.View(section);
|
||||
// Clear views
|
||||
// this.clear();
|
||||
this.fill(view);
|
||||
// rendered = this.render(section);
|
||||
|
||||
// if(this.settings.infinite) {
|
||||
// rendered.then(function(){
|
||||
// return this.fill.call(this);
|
||||
// }.bind(this));
|
||||
// }
|
||||
this.check();
|
||||
|
||||
view.displayed.then(function(){
|
||||
this.trigger("displayed", section);
|
||||
this.displaying = false;
|
||||
displaying.resolve(this);
|
||||
}.bind(this));
|
||||
|
||||
} else {
|
||||
displaying.reject(new Error("No Section Found"));
|
||||
}
|
||||
|
||||
}.bind(this));
|
||||
} else {
|
||||
displaying.reject(new Error("No Section Found"));
|
||||
}
|
||||
|
||||
return displayed;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue