]> git.parisson.com Git - pdf.js.git/commitdiff
Fixing initial scale when named destination is specified
authornotmasteryet <async.processingjs@yahoo.com>
Thu, 26 Jan 2012 03:52:10 +0000 (21:52 -0600)
committernotmasteryet <async.processingjs@yahoo.com>
Thu, 26 Jan 2012 03:52:10 +0000 (21:52 -0600)
web/viewer.js

index dcd3f51b664a8777aff44ae3fc4141f3a433b51c..dd16b02820bb58b2dbfc15b711ad09c45fc43855 100644 (file)
@@ -6,6 +6,7 @@
 var kDefaultURL = 'compressed.tracemonkey-pldi-09.pdf';
 var kDefaultScale = 'auto';
 var kDefaultScaleDelta = 1.1;
+var kUnknownScale = 0;
 var kCacheSize = 20;
 var kCssUnits = 96.0 / 72.0;
 var kScrollbarPadding = 40;
@@ -148,7 +149,7 @@ var currentPageNumber = 1;
 var PDFView = {
   pages: [],
   thumbnails: [],
-  currentScale: 0,
+  currentScale: kUnknownScale,
   currentScaleValue: null,
   initialBookmark: document.location.hash.substring(1),
 
@@ -452,10 +453,16 @@ var PDFView = {
     }
     else if (storedHash)
       this.setHash(storedHash);
-    else {
-      this.parseScale(scale || kDefaultScale, true);
+    else if (scale) {
+      this.parseScale(scale, true);
       this.page = 1;
     }
+
+    if (PDFView.currentScale === kUnknownScale) {
+      // Scale was not initialized: invalid bookmark or scale was not specified.
+      // Setting the default one.
+      this.parseScale(kDefaultScale, true);
+    }
   },
 
   setHash: function pdfViewSetHash(hash) {
@@ -742,6 +749,8 @@ var PageView = function pageView(container, content, id, pageWidth, pageHeight,
 
       if (scale && scale !== PDFView.currentScale)
         PDFView.parseScale(scale, true);
+      else if (PDFView.currentScale === kUnknownScale)
+        PDFView.parseScale(kDefaultScale, true);
 
       setTimeout(function pageViewScrollIntoViewRelayout() {
         // letting page to re-layout before scrolling