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

Fix display callback

This commit is contained in:
fchasen 2015-06-30 22:06:14 -04:00
parent 3e9f8a609a
commit 2e2d7dfb43
6 changed files with 59 additions and 47 deletions

46
dist/epub.js vendored
View file

@ -4805,7 +4805,7 @@ EPUBJS.Layout.Reflowable.prototype.format = function(view){
//-- Add columns
$body.style[this.columnAxis] = "horizontal";
$body.style[this.columnFill] = "balance";
$body.style[this.columnFill] = "auto";
$body.style[this.columnGap] = this.gap+"px";
$body.style[this.columnWidth] = this.column+"px";
@ -5090,8 +5090,10 @@ EPUBJS.Rendition.prototype._display = function(target){
if(visible) {
offset = view.locationOf(target);
this.q.enqueue(this.moveTo, offset);
this.q.enqueue(this.check);
displayed = this.moveTo(offset)
.then(function(){
return this.check();
});
} else {
// Hide all current views
@ -5101,7 +5103,7 @@ EPUBJS.Rendition.prototype._display = function(target){
view = new EPUBJS.View(section, this.viewSettings);
// This will clear all previous views
this.fill(view)
displayed = this.fill(view)
.then(function(){
// Parse the target fragment
@ -5113,25 +5115,28 @@ EPUBJS.Rendition.prototype._display = function(target){
// Move to correct place within the section, if needed
if(cfi || fragment) {
offset = view.locationOf(target);
return this.q.enqueue(this.moveTo, offset);
return this.moveTo(offset);
}
if(typeof this.check === 'function') {
return this.q.enqueue(this.check);
return this.check();
}
}.bind(this))
.then(this.views.show.bind(this.views));
.then(function(){
return this.hooks.display.trigger(view);
}.bind(this))
.then(function(){
this.views.show();
}.bind(this));
}
displayed.then(function(){
// This hook doesn't prevent showing, but waits to resolve until
// all the hooks have finished. Might want to block showing.
this.hooks.display.trigger(view)
.then(function(){
this.trigger("displayed", section);
displaying.resolve(this);
}.bind(this));
return displayed;
};
@ -6020,7 +6025,7 @@ EPUBJS.Paginate.prototype.start = function(){
// this.hooks.display.register(this.reportLocation);
this.on('displayed', this.reportLocation.bind(this));
this.hooks.content.register(this.adjustImages.bind(this));
// this.hooks.content.register(this.adjustImages.bind(this));
this.currentPage = 0;
@ -6116,12 +6121,12 @@ EPUBJS.Paginate.prototype.prev = function(){
// return this.page(this.currentPage - 1);
};
EPUBJS.Paginate.prototype.reportLocation = function(){
return this.q.enqueue(function(){
this.location = this.currentLocation();
this.trigger("locationChanged", this.location);
}.bind(this));
};
// EPUBJS.Paginate.prototype.reportLocation = function(){
// return this.q.enqueue(function(){
// this.location = this.currentLocation();
// this.trigger("locationChanged", this.location);
// }.bind(this));
// };
EPUBJS.Paginate.prototype.currentLocation = function(){
var visible = this.visible();
@ -6154,7 +6159,6 @@ EPUBJS.Paginate.prototype.currentLocation = function(){
end: pageRight.end
};
}
};
EPUBJS.Paginate.prototype.resize = function(width, height){
@ -6165,7 +6169,9 @@ EPUBJS.Paginate.prototype.resize = function(width, height){
this.updateLayout();
if(this.location) {
this.display(this.location.start);
}
this.trigger("resized", {
width: this.stage.width,

4
dist/epub.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -126,7 +126,7 @@
height: 600
});
var displayed = rendition.display(12);
var displayed = rendition.display();
displayed.then(function(renderer){

View file

@ -64,7 +64,7 @@ EPUBJS.Layout.Reflowable.prototype.format = function(view){
//-- Add columns
$body.style[this.columnAxis] = "horizontal";
$body.style[this.columnFill] = "balance";
$body.style[this.columnFill] = "auto";
$body.style[this.columnGap] = this.gap+"px";
$body.style[this.columnWidth] = this.column+"px";

View file

@ -92,7 +92,7 @@ EPUBJS.Paginate.prototype.start = function(){
// this.hooks.display.register(this.reportLocation);
this.on('displayed', this.reportLocation.bind(this));
this.hooks.content.register(this.adjustImages.bind(this));
// this.hooks.content.register(this.adjustImages.bind(this));
this.currentPage = 0;
@ -188,12 +188,12 @@ EPUBJS.Paginate.prototype.prev = function(){
// return this.page(this.currentPage - 1);
};
EPUBJS.Paginate.prototype.reportLocation = function(){
return this.q.enqueue(function(){
this.location = this.currentLocation();
this.trigger("locationChanged", this.location);
}.bind(this));
};
// EPUBJS.Paginate.prototype.reportLocation = function(){
// return this.q.enqueue(function(){
// this.location = this.currentLocation();
// this.trigger("locationChanged", this.location);
// }.bind(this));
// };
EPUBJS.Paginate.prototype.currentLocation = function(){
var visible = this.visible();
@ -226,7 +226,6 @@ EPUBJS.Paginate.prototype.currentLocation = function(){
end: pageRight.end
};
}
};
EPUBJS.Paginate.prototype.resize = function(width, height){
@ -237,7 +236,9 @@ EPUBJS.Paginate.prototype.resize = function(width, height){
this.updateLayout();
if(this.location) {
this.display(this.location.start);
}
this.trigger("resized", {
width: this.stage.width,

View file

@ -193,8 +193,10 @@ EPUBJS.Rendition.prototype._display = function(target){
if(visible) {
offset = view.locationOf(target);
this.q.enqueue(this.moveTo, offset);
this.q.enqueue(this.check);
displayed = this.moveTo(offset)
.then(function(){
return this.check();
});
} else {
// Hide all current views
@ -204,7 +206,7 @@ EPUBJS.Rendition.prototype._display = function(target){
view = new EPUBJS.View(section, this.viewSettings);
// This will clear all previous views
this.fill(view)
displayed = this.fill(view)
.then(function(){
// Parse the target fragment
@ -216,25 +218,28 @@ EPUBJS.Rendition.prototype._display = function(target){
// Move to correct place within the section, if needed
if(cfi || fragment) {
offset = view.locationOf(target);
return this.q.enqueue(this.moveTo, offset);
return this.moveTo(offset);
}
if(typeof this.check === 'function') {
return this.q.enqueue(this.check);
return this.check();
}
}.bind(this))
.then(this.views.show.bind(this.views));
.then(function(){
return this.hooks.display.trigger(view);
}.bind(this))
.then(function(){
this.views.show();
}.bind(this));
}
displayed.then(function(){
// This hook doesn't prevent showing, but waits to resolve until
// all the hooks have finished. Might want to block showing.
this.hooks.display.trigger(view)
.then(function(){
this.trigger("displayed", section);
displaying.resolve(this);
}.bind(this));
return displayed;
};