Ensure that any pending rendering operations in PDFViewer/PDFThumbnailViewer are cancelled when the viewer is closed

This commit is contained in:
Jonas Jenwald 2016-07-29 20:39:22 +02:00
parent fb5aa58008
commit a824c6c4f6
5 changed files with 66 additions and 27 deletions

View file

@ -135,15 +135,14 @@ var PDFThumbnailViewer = (function PDFThumbnailViewerClosure() {
this.thumbnails = [];
this._pagesRotation = 0;
this._pagesRequests = [];
// Remove the thumbnails from the DOM.
this.container.textContent = '';
},
setDocument: function PDFThumbnailViewer_setDocument(pdfDocument) {
if (this.pdfDocument) {
// cleanup of the elements and views
var thumbsView = this.container;
while (thumbsView.hasChildNodes()) {
thumbsView.removeChild(thumbsView.lastChild);
}
this._cancelRendering();
this._resetView();
}
@ -169,6 +168,17 @@ var PDFThumbnailViewer = (function PDFThumbnailViewerClosure() {
}.bind(this));
},
/**
* @private
*/
_cancelRendering: function PDFThumbnailViewer_cancelRendering() {
for (var i = 0, ii = this.thumbnails.length; i < ii; i++) {
if (this.thumbnails[i]) {
this.thumbnails[i].cancelRendering();
}
}
},
/**
* @param {PDFThumbnailView} thumbView
* @returns {PDFPage}