mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Cleaning up fonts when viewer is idle for some time
This commit is contained in:
parent
945e370d4f
commit
e712c4136a
9 changed files with 93 additions and 9 deletions
|
@ -67,12 +67,16 @@ var PageView = function pageView(container, id, scale,
|
|||
}
|
||||
};
|
||||
|
||||
this.reset = function pageViewReset() {
|
||||
this.resetRenderingState = function pageViewResetRenderingState() {
|
||||
if (this.renderTask) {
|
||||
this.renderTask.cancel();
|
||||
}
|
||||
this.resume = null;
|
||||
this.renderingState = RenderingStates.INITIAL;
|
||||
};
|
||||
|
||||
this.reset = function pageViewReset() {
|
||||
this.resetRenderingState();
|
||||
|
||||
div.style.width = Math.floor(this.viewport.width) + 'px';
|
||||
div.style.height = Math.floor(this.viewport.height) + 'px';
|
||||
|
|
|
@ -38,6 +38,7 @@ var SCALE_SELECT_CONTAINER_PADDING = 8;
|
|||
var SCALE_SELECT_PADDING = 22;
|
||||
var THUMBNAIL_SCROLL_MARGIN = -19;
|
||||
var USE_ONLY_CSS_ZOOM = false;
|
||||
var CLEANUP_TIMEOUT = 30000;
|
||||
//#if B2G
|
||||
//USE_ONLY_CSS_ZOOM = true;
|
||||
//#endif
|
||||
|
@ -106,6 +107,7 @@ var PDFView = {
|
|||
lastScroll: 0,
|
||||
previousPageNumber: 1,
|
||||
isViewerEmbedded: (window.parent !== window),
|
||||
idleTimeout: null,
|
||||
|
||||
// called once when the document is loaded
|
||||
initialize: function pdfViewInitialize() {
|
||||
|
@ -1011,6 +1013,11 @@ var PDFView = {
|
|||
},
|
||||
|
||||
renderHighestPriority: function pdfViewRenderHighestPriority() {
|
||||
if (PDFView.idleTimeout) {
|
||||
clearTimeout(PDFView.idleTimeout);
|
||||
PDFView.idleTimeout = null;
|
||||
}
|
||||
|
||||
// Pages have a higher priority than thumbnails, so check them first.
|
||||
var visiblePages = this.getVisiblePages();
|
||||
var pageView = this.getHighestPriority(visiblePages, this.pages,
|
||||
|
@ -1025,9 +1032,24 @@ var PDFView = {
|
|||
var thumbView = this.getHighestPriority(visibleThumbs,
|
||||
this.thumbnails,
|
||||
this.thumbnailViewScroll.down);
|
||||
if (thumbView)
|
||||
if (thumbView) {
|
||||
this.renderView(thumbView, 'thumbnail');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
PDFView.idleTimeout = setTimeout(function () {
|
||||
PDFView.cleanup();
|
||||
}, CLEANUP_TIMEOUT);
|
||||
},
|
||||
|
||||
cleanup: function pdfViewCleanup() {
|
||||
for (var i = 0, ii = this.pages.length; i < ii; i++) {
|
||||
if (this.pages[i]) {
|
||||
this.pages[i].resetRenderingState();
|
||||
}
|
||||
}
|
||||
this.pdfDocument.cleanup();
|
||||
},
|
||||
|
||||
getHighestPriority: function pdfViewGetHighestPriority(visible, views,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue