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:
parent
3e9f8a609a
commit
2e2d7dfb43
6 changed files with 59 additions and 47 deletions
46
dist/epub.js
vendored
46
dist/epub.js
vendored
|
@ -4805,7 +4805,7 @@ EPUBJS.Layout.Reflowable.prototype.format = function(view){
|
||||||
|
|
||||||
//-- Add columns
|
//-- Add columns
|
||||||
$body.style[this.columnAxis] = "horizontal";
|
$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.columnGap] = this.gap+"px";
|
||||||
$body.style[this.columnWidth] = this.column+"px";
|
$body.style[this.columnWidth] = this.column+"px";
|
||||||
|
|
||||||
|
@ -5090,8 +5090,10 @@ EPUBJS.Rendition.prototype._display = function(target){
|
||||||
|
|
||||||
if(visible) {
|
if(visible) {
|
||||||
offset = view.locationOf(target);
|
offset = view.locationOf(target);
|
||||||
this.q.enqueue(this.moveTo, offset);
|
displayed = this.moveTo(offset)
|
||||||
this.q.enqueue(this.check);
|
.then(function(){
|
||||||
|
return this.check();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Hide all current views
|
// Hide all current views
|
||||||
|
@ -5101,7 +5103,7 @@ EPUBJS.Rendition.prototype._display = function(target){
|
||||||
view = new EPUBJS.View(section, this.viewSettings);
|
view = new EPUBJS.View(section, this.viewSettings);
|
||||||
|
|
||||||
// This will clear all previous views
|
// This will clear all previous views
|
||||||
this.fill(view)
|
displayed = this.fill(view)
|
||||||
.then(function(){
|
.then(function(){
|
||||||
|
|
||||||
// Parse the target fragment
|
// Parse the target fragment
|
||||||
|
@ -5113,25 +5115,28 @@ EPUBJS.Rendition.prototype._display = function(target){
|
||||||
// Move to correct place within the section, if needed
|
// Move to correct place within the section, if needed
|
||||||
if(cfi || fragment) {
|
if(cfi || fragment) {
|
||||||
offset = view.locationOf(target);
|
offset = view.locationOf(target);
|
||||||
return this.q.enqueue(this.moveTo, offset);
|
return this.moveTo(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof this.check === 'function') {
|
if(typeof this.check === 'function') {
|
||||||
return this.q.enqueue(this.check);
|
return this.check();
|
||||||
}
|
}
|
||||||
}.bind(this))
|
}.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);
|
this.trigger("displayed", section);
|
||||||
displaying.resolve(this);
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
|
||||||
return displayed;
|
return displayed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6020,7 +6025,7 @@ EPUBJS.Paginate.prototype.start = function(){
|
||||||
// this.hooks.display.register(this.reportLocation);
|
// this.hooks.display.register(this.reportLocation);
|
||||||
this.on('displayed', this.reportLocation.bind(this));
|
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;
|
this.currentPage = 0;
|
||||||
|
|
||||||
|
@ -6116,12 +6121,12 @@ EPUBJS.Paginate.prototype.prev = function(){
|
||||||
// return this.page(this.currentPage - 1);
|
// return this.page(this.currentPage - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Paginate.prototype.reportLocation = function(){
|
// EPUBJS.Paginate.prototype.reportLocation = function(){
|
||||||
return this.q.enqueue(function(){
|
// return this.q.enqueue(function(){
|
||||||
this.location = this.currentLocation();
|
// this.location = this.currentLocation();
|
||||||
this.trigger("locationChanged", this.location);
|
// this.trigger("locationChanged", this.location);
|
||||||
}.bind(this));
|
// }.bind(this));
|
||||||
};
|
// };
|
||||||
|
|
||||||
EPUBJS.Paginate.prototype.currentLocation = function(){
|
EPUBJS.Paginate.prototype.currentLocation = function(){
|
||||||
var visible = this.visible();
|
var visible = this.visible();
|
||||||
|
@ -6154,7 +6159,6 @@ EPUBJS.Paginate.prototype.currentLocation = function(){
|
||||||
end: pageRight.end
|
end: pageRight.end
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Paginate.prototype.resize = function(width, height){
|
EPUBJS.Paginate.prototype.resize = function(width, height){
|
||||||
|
@ -6165,7 +6169,9 @@ EPUBJS.Paginate.prototype.resize = function(width, height){
|
||||||
|
|
||||||
this.updateLayout();
|
this.updateLayout();
|
||||||
|
|
||||||
|
if(this.location) {
|
||||||
this.display(this.location.start);
|
this.display(this.location.start);
|
||||||
|
}
|
||||||
|
|
||||||
this.trigger("resized", {
|
this.trigger("resized", {
|
||||||
width: this.stage.width,
|
width: this.stage.width,
|
||||||
|
|
4
dist/epub.min.js
vendored
4
dist/epub.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -126,7 +126,7 @@
|
||||||
height: 600
|
height: 600
|
||||||
});
|
});
|
||||||
|
|
||||||
var displayed = rendition.display(12);
|
var displayed = rendition.display();
|
||||||
|
|
||||||
|
|
||||||
displayed.then(function(renderer){
|
displayed.then(function(renderer){
|
||||||
|
|
|
@ -64,7 +64,7 @@ EPUBJS.Layout.Reflowable.prototype.format = function(view){
|
||||||
|
|
||||||
//-- Add columns
|
//-- Add columns
|
||||||
$body.style[this.columnAxis] = "horizontal";
|
$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.columnGap] = this.gap+"px";
|
||||||
$body.style[this.columnWidth] = this.column+"px";
|
$body.style[this.columnWidth] = this.column+"px";
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ EPUBJS.Paginate.prototype.start = function(){
|
||||||
// this.hooks.display.register(this.reportLocation);
|
// this.hooks.display.register(this.reportLocation);
|
||||||
this.on('displayed', this.reportLocation.bind(this));
|
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;
|
this.currentPage = 0;
|
||||||
|
|
||||||
|
@ -188,12 +188,12 @@ EPUBJS.Paginate.prototype.prev = function(){
|
||||||
// return this.page(this.currentPage - 1);
|
// return this.page(this.currentPage - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Paginate.prototype.reportLocation = function(){
|
// EPUBJS.Paginate.prototype.reportLocation = function(){
|
||||||
return this.q.enqueue(function(){
|
// return this.q.enqueue(function(){
|
||||||
this.location = this.currentLocation();
|
// this.location = this.currentLocation();
|
||||||
this.trigger("locationChanged", this.location);
|
// this.trigger("locationChanged", this.location);
|
||||||
}.bind(this));
|
// }.bind(this));
|
||||||
};
|
// };
|
||||||
|
|
||||||
EPUBJS.Paginate.prototype.currentLocation = function(){
|
EPUBJS.Paginate.prototype.currentLocation = function(){
|
||||||
var visible = this.visible();
|
var visible = this.visible();
|
||||||
|
@ -226,7 +226,6 @@ EPUBJS.Paginate.prototype.currentLocation = function(){
|
||||||
end: pageRight.end
|
end: pageRight.end
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EPUBJS.Paginate.prototype.resize = function(width, height){
|
EPUBJS.Paginate.prototype.resize = function(width, height){
|
||||||
|
@ -237,7 +236,9 @@ EPUBJS.Paginate.prototype.resize = function(width, height){
|
||||||
|
|
||||||
this.updateLayout();
|
this.updateLayout();
|
||||||
|
|
||||||
|
if(this.location) {
|
||||||
this.display(this.location.start);
|
this.display(this.location.start);
|
||||||
|
}
|
||||||
|
|
||||||
this.trigger("resized", {
|
this.trigger("resized", {
|
||||||
width: this.stage.width,
|
width: this.stage.width,
|
||||||
|
|
|
@ -193,8 +193,10 @@ EPUBJS.Rendition.prototype._display = function(target){
|
||||||
|
|
||||||
if(visible) {
|
if(visible) {
|
||||||
offset = view.locationOf(target);
|
offset = view.locationOf(target);
|
||||||
this.q.enqueue(this.moveTo, offset);
|
displayed = this.moveTo(offset)
|
||||||
this.q.enqueue(this.check);
|
.then(function(){
|
||||||
|
return this.check();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Hide all current views
|
// Hide all current views
|
||||||
|
@ -204,7 +206,7 @@ EPUBJS.Rendition.prototype._display = function(target){
|
||||||
view = new EPUBJS.View(section, this.viewSettings);
|
view = new EPUBJS.View(section, this.viewSettings);
|
||||||
|
|
||||||
// This will clear all previous views
|
// This will clear all previous views
|
||||||
this.fill(view)
|
displayed = this.fill(view)
|
||||||
.then(function(){
|
.then(function(){
|
||||||
|
|
||||||
// Parse the target fragment
|
// Parse the target fragment
|
||||||
|
@ -216,25 +218,28 @@ EPUBJS.Rendition.prototype._display = function(target){
|
||||||
// Move to correct place within the section, if needed
|
// Move to correct place within the section, if needed
|
||||||
if(cfi || fragment) {
|
if(cfi || fragment) {
|
||||||
offset = view.locationOf(target);
|
offset = view.locationOf(target);
|
||||||
return this.q.enqueue(this.moveTo, offset);
|
return this.moveTo(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(typeof this.check === 'function') {
|
if(typeof this.check === 'function') {
|
||||||
return this.q.enqueue(this.check);
|
return this.check();
|
||||||
}
|
}
|
||||||
}.bind(this))
|
}.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);
|
this.trigger("displayed", section);
|
||||||
displaying.resolve(this);
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
|
||||||
return displayed;
|
return displayed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue