[Pkg-javascript-commits] [pdf.js] 245/414: Remove `PDFThumbnailViewer_ensureThumbnailVisible`

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:26 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 39cba5d25d45c439cbc9667f8cfbea008b0e6d86
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Sun Feb 28 13:16:08 2016 +0100

    Remove `PDFThumbnailViewer_ensureThumbnailVisible`
    
    Functionality wise, `ensureThumbnailVisible` is essentially just a shorthand for `scrollThumbnailIntoView`. (And note that `PDFViewer` doesn't implement a `ensurePageVisible` method.)
    
    The only remaining usage of `PDFThumbnailViewer_ensureThumbnailVisible` is inside `PDFPresentationMode`, which introduces an otherwise unnecessary `PDFThumbnailViewer` dependency there.
    
    We're already relying on the `presentationmodechanged` event, in various files, to track the state of Presentation Mode. Thus we can simply listen for that event in `PDFSidebar` too, and update the thumbnails if necessary.
---
 web/pdf_presentation_mode.js | 7 -------
 web/pdf_sidebar.js           | 8 ++++++++
 web/pdf_thumbnail_viewer.js  | 7 -------
 web/viewer.js                | 1 -
 4 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/web/pdf_presentation_mode.js b/web/pdf_presentation_mode.js
index 5b492ce..4da6f34 100644
--- a/web/pdf_presentation_mode.js
+++ b/web/pdf_presentation_mode.js
@@ -25,8 +25,6 @@ var CONTROLS_SELECTOR = 'pdfPresentationModeControls';
  * @property {HTMLDivElement} container - The container for the viewer element.
  * @property {HTMLDivElement} viewer - (optional) The viewer element.
  * @property {PDFViewer} pdfViewer - The document viewer.
- * @property {PDFThumbnailViewer} pdfThumbnailViewer - (optional) The thumbnail
- *   viewer.
  * @property {Array} contextMenuItems - (optional) The menuitems that are added
  *   to the context menu in Presentation Mode.
  */
@@ -43,7 +41,6 @@ var PDFPresentationMode = (function PDFPresentationModeClosure() {
     this.container = options.container;
     this.viewer = options.viewer || options.container.firstElementChild;
     this.pdfViewer = options.pdfViewer;
-    this.pdfThumbnailViewer = options.pdfThumbnailViewer || null;
     var contextMenuItems = options.contextMenuItems || null;
 
     this.active = false;
@@ -245,10 +242,6 @@ var PDFPresentationMode = (function PDFPresentationModeClosure() {
       this._resetMouseScrollState();
       this.container.removeAttribute('contextmenu');
       this.contextMenuOpen = false;
-
-      if (this.pdfThumbnailViewer) {
-        this.pdfThumbnailViewer.ensureThumbnailVisible(page);
-      }
     },
 
     /**
diff --git a/web/pdf_sidebar.js b/web/pdf_sidebar.js
index 0490ef2..aa78803 100644
--- a/web/pdf_sidebar.js
+++ b/web/pdf_sidebar.js
@@ -317,6 +317,14 @@ var PDFSidebar = (function PDFSidebarClosure() {
           self.switchView(SidebarView.THUMBS);
         }
       });
+
+      // Update the thumbnailViewer, if visible, when exiting presentation mode.
+      window.addEventListener('presentationmodechanged', function(evt) {
+        if (!evt.detail.active && !evt.detail.switchInProgress &&
+            self.isThumbnailViewVisible) {
+          self._updateThumbnailViewer();
+        }
+      });
     },
   };
 
diff --git a/web/pdf_thumbnail_viewer.js b/web/pdf_thumbnail_viewer.js
index 816b314..c76b9be 100644
--- a/web/pdf_thumbnail_viewer.js
+++ b/web/pdf_thumbnail_viewer.js
@@ -178,13 +178,6 @@ var PDFThumbnailViewer = (function PDFThumbnailViewerClosure() {
       return promise;
     },
 
-    ensureThumbnailVisible:
-        function PDFThumbnailViewer_ensureThumbnailVisible(page) {
-      // Ensure that the thumbnail of the current page is visible
-      // when switching from another view.
-      scrollIntoView(document.getElementById('thumbnailContainer' + page));
-    },
-
     forceRendering: function () {
       var visibleThumbs = this._getVisibleThumbs();
       var thumbView = this.renderingQueue.getHighestPriority(visibleThumbs,
diff --git a/web/viewer.js b/web/viewer.js
index 1ab9ca3..a478e11 100644
--- a/web/viewer.js
+++ b/web/viewer.js
@@ -229,7 +229,6 @@ var PDFViewerApplication = {
         container: container,
         viewer: viewer,
         pdfViewer: this.pdfViewer,
-        pdfThumbnailViewer: this.pdfThumbnailViewer,
         contextMenuItems: [
           { element: document.getElementById('contextFirstPage'),
             handler: toolbar.firstPageClick.bind(toolbar) },

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list