From d940078d955dc3e2a6d07953adad09372502963e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 30 Jun 2015 21:49:32 +0200 Subject: [PATCH] Make sure that the document is rendered on zooming and rotation for `PDFViewer` instances using the `defaultRenderingQueue` In `viewer.js` we have code that ensures that the document is re-rendered on zooming and rotation. However, for `components` based viewers this might not work correctly, since there's currently no code which handles that. Note that there is a good chance that this "just works" in many `components` viewers already, thanks to the `watchScroll` function. The explanation is that zooming or rotation, most of the time, causes the viewer to change its (scrollable) size, thus triggering `PDFViewer_update` through `PDFViewer_scrollUpdate`. However, in general there's no guarantee that this will actually work (since zooming and rotation doesn't necessarily change the size of the viewer for all documents), and requiring every viewer `components` implementer to provide methods for this doesn't seem like a great idea. --- web/pdf_viewer.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index 75dcf32a1..e3f813f76 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -205,6 +205,10 @@ var PDFViewer = (function pdfViewer() { } this._setScale(this._currentScaleValue, true); + + if (this.defaultRenderingQueue) { + this.update(); + } }, /** @@ -342,7 +346,7 @@ var PDFViewer = (function pdfViewer() { } }, - _scrollUpdate: function () { + _scrollUpdate: function PDFViewer_scrollUpdate() { if (this.pagesCount === 0) { return; } @@ -390,6 +394,10 @@ var PDFViewer = (function pdfViewer() { } this._setScaleDispatchEvent(newScale, newValue, preset); + + if (this.defaultRenderingQueue) { + this.update(); + } }, _setScale: function pdfViewer_setScale(value, noScroll) {