mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
New queue flush, handle cfi for display, re-display on resize
This commit is contained in:
parent
42efc34517
commit
ac926479cf
12 changed files with 941 additions and 399 deletions
|
@ -40,7 +40,9 @@ EPUBJS.Queue.prototype.enqueue = function() {
|
|||
|
||||
this._q.push(queued);
|
||||
|
||||
|
||||
// Wait to start queue flush
|
||||
setTimeout(this.flush.bind(this), 0);
|
||||
|
||||
return queued.promise;
|
||||
};
|
||||
|
||||
|
@ -83,13 +85,14 @@ EPUBJS.Queue.prototype.dequeue = function(){
|
|||
};
|
||||
|
||||
// Run All Immediately
|
||||
EPUBJS.Queue.prototype.flush = function(){
|
||||
EPUBJS.Queue.prototype.dump = function(){
|
||||
while(this._q.length) {
|
||||
this.dequeue();
|
||||
}
|
||||
};
|
||||
|
||||
// Run all sequentially, at convince
|
||||
|
||||
EPUBJS.Queue.prototype.run = function(){
|
||||
if(!this.running && this._q.length) {
|
||||
this.running = true;
|
||||
|
@ -101,9 +104,28 @@ EPUBJS.Queue.prototype.run = function(){
|
|||
this.tick.call(window, this.run.bind(this));
|
||||
};
|
||||
|
||||
// Flush all, as quickly as possible
|
||||
EPUBJS.Queue.prototype.flush = function(){
|
||||
if(this.running){
|
||||
return this.running;
|
||||
}
|
||||
|
||||
if(this._q.length) {
|
||||
this.running = this.dequeue().
|
||||
then(function(){
|
||||
this.running = undefined;
|
||||
return this.flush();
|
||||
}.bind(this));
|
||||
|
||||
return this.running;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Clear all items in wait
|
||||
EPUBJS.Queue.prototype.clear = function(){
|
||||
this._q = [];
|
||||
this.running = false;
|
||||
};
|
||||
|
||||
EPUBJS.Queue.prototype.length = function(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue