mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-05 15:32:55 +02:00
compressed epub updates to prevent after display firing twice
This commit is contained in:
parent
315312a89c
commit
abd123ef91
13 changed files with 111 additions and 47 deletions
File diff suppressed because one or more lines are too long
36
reader/js/epub.min.js
vendored
36
reader/js/epub.min.js
vendored
|
@ -3420,9 +3420,9 @@ EPUBJS.Book.prototype._registerReplacements = function(renderer){
|
|||
if(this._needsAssetReplacement()) {
|
||||
|
||||
renderer.registerHook("beforeChapterDisplay", [
|
||||
EPUBJS.replace.head,
|
||||
EPUBJS.replace.resources,
|
||||
EPUBJS.replace.svg
|
||||
EPUBJS.replace.head
|
||||
// EPUBJS.replace.resources,
|
||||
// EPUBJS.replace.svg
|
||||
], true);
|
||||
|
||||
}
|
||||
|
@ -3514,11 +3514,17 @@ EPUBJS.Chapter.prototype.url = function(_store){
|
|||
|
||||
if(store){
|
||||
if(!this.tempUrl) {
|
||||
this.tempUrl = store.getUrl(this.absolute);
|
||||
store.getUrl(this.absolute).then(function(url){
|
||||
chapter.tempUrl = url;
|
||||
deferred.resolve(url);
|
||||
});
|
||||
} else {
|
||||
url = this.tempUrl;
|
||||
deferred.resolve(url);
|
||||
}
|
||||
url = this.tempUrl;
|
||||
}else{
|
||||
url = this.absolute;
|
||||
deferred.resolve(url);
|
||||
}
|
||||
/*
|
||||
loaded = EPUBJS.core.request(url, 'xml', false);
|
||||
|
@ -3529,7 +3535,6 @@ EPUBJS.Chapter.prototype.url = function(_store){
|
|||
deferred.reject(error);
|
||||
});
|
||||
*/
|
||||
deferred.resolve(url);
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
@ -4740,8 +4745,8 @@ EPUBJS.Hooks = (function(){
|
|||
}
|
||||
|
||||
function countdown(){
|
||||
count--;
|
||||
if(count <= 0 && callback) callback();
|
||||
count--;
|
||||
}
|
||||
|
||||
hooks.forEach(function(hook){
|
||||
|
@ -5741,6 +5746,10 @@ EPUBJS.Renderer = function(renderMethod, hidden) {
|
|||
EPUBJS.Hooks.mixin(this);
|
||||
//-- Get pre-registered hooks for events
|
||||
this.getHooks("beforeChapterDisplay");
|
||||
|
||||
//-- Queue up page changes if page map isn't ready
|
||||
this._q = EPUBJS.core.queue(this);
|
||||
|
||||
};
|
||||
|
||||
//-- Renderer events for listening
|
||||
|
@ -5861,7 +5870,6 @@ EPUBJS.Renderer.prototype.load = function(url){
|
|||
this.beforeDisplay(function(){
|
||||
var pages = this.layout.calculatePages();
|
||||
var msg = this.currentChapter;
|
||||
|
||||
this.updatePages(pages);
|
||||
|
||||
this.visibleRangeCfi = this.getVisibleRangeCfi();
|
||||
|
@ -5966,6 +5974,8 @@ EPUBJS.Renderer.prototype.updatePages = function(layout){
|
|||
this.pageMap = this.mapPage();
|
||||
this.displayedPages = layout.displayedPages;
|
||||
this.currentChapter.pages = layout.pageCount;
|
||||
|
||||
this._q.flush();
|
||||
};
|
||||
|
||||
// Apply the layout again and jump back to the previous cfi position
|
||||
|
@ -6045,7 +6055,13 @@ EPUBJS.Renderer.prototype.applyHeadTags = function(headTags) {
|
|||
|
||||
//-- NAVIGATION
|
||||
|
||||
EPUBJS.Renderer.prototype.page = function(pg){
|
||||
EPUBJS.Renderer.prototype.page = function(pg){
|
||||
|
||||
if(!this.pageMap) {
|
||||
this._q.enqueue("page", arguments);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(pg >= 1 && pg <= this.displayedPages){
|
||||
this.chapterPos = pg;
|
||||
|
||||
|
@ -6501,7 +6517,7 @@ EPUBJS.Renderer.prototype.getVisibleRangeCfi = function(){
|
|||
}
|
||||
|
||||
if(!startRange) {
|
||||
console.warn("startRange miss:", this.pageMap, pg);
|
||||
console.warn("page range miss:", pg);
|
||||
startRange = this.pageMap[this.pageMap.length-1];
|
||||
endRange = startRange;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue