From 13ec738798b8f4c88a0fcd8234f99b09b7928be6 Mon Sep 17 00:00:00 2001 From: Pdf Bot Date: Thu, 5 Nov 2015 16:52:09 +0000 Subject: [PATCH] PDF.js version 1.2.68 - See mozilla/pdf.js@8079bdddb9bfc2c8f9050bdd3486db9bdb4e7871 --- bower.json | 2 +- build/pdf.combined.js | 4 ++-- build/pdf.js | 4 ++-- build/pdf.worker.js | 4 ++-- package.json | 2 +- web/pdf_viewer.css | 18 ++++++++++++++++++ web/pdf_viewer.js | 41 ++++++++++++++++++++++++++++++++++++++++- 7 files changed, 66 insertions(+), 9 deletions(-) diff --git a/bower.json b/bower.json index 82cb9d053..a7a172cea 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.2.66", + "version": "1.2.68", "main": [ "build/pdf.js", "build/pdf.worker.js" diff --git a/build/pdf.combined.js b/build/pdf.combined.js index 55fcb0554..0c15e9a26 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.2.66'; -PDFJS.build = 'c05416f'; +PDFJS.version = '1.2.68'; +PDFJS.build = '8079bdd'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it diff --git a/build/pdf.js b/build/pdf.js index 846b3657d..b21eb56c5 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.2.66'; -PDFJS.build = 'c05416f'; +PDFJS.version = '1.2.68'; +PDFJS.build = '8079bdd'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it diff --git a/build/pdf.worker.js b/build/pdf.worker.js index 316716d57..48f6ec990 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.2.66'; -PDFJS.build = 'c05416f'; +PDFJS.version = '1.2.68'; +PDFJS.build = '8079bdd'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it diff --git a/package.json b/package.json index 8ca12fcff..585db650f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.2.66", + "version": "1.2.68", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [ "Mozilla", diff --git a/web/pdf_viewer.css b/web/pdf_viewer.css index 73026813b..c14d0a6b3 100644 --- a/web/pdf_viewer.css +++ b/web/pdf_viewer.css @@ -62,6 +62,24 @@ .textLayer ::selection { background: rgb(0,0,255); } .textLayer ::-moz-selection { background: rgb(0,0,255); } +.textLayer .endOfContent { + display: block; + position: absolute; + left: 0px; + top: 100%; + right: 0px; + bottom: 0px; + z-index: -1; + cursor: default; + -webkit-user-select: none; + -ms-user-select: none; + -moz-user-select: none; +} + +.textLayer .endOfContent.active { + top: 0px; +} + .annotationLayer .annotLink > a:hover { opacity: 0.2; diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index 384913b50..f41e3fb38 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -1506,12 +1506,17 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { this.viewport = options.viewport; this.textDivs = []; this.findController = options.findController || null; + this._bindMouse(); } TextLayerBuilder.prototype = { _finishRendering: function TextLayerBuilder_finishRendering() { this.renderingDone = true; + var endOfContent = document.createElement('div'); + endOfContent.className = 'endOfContent'; + this.textLayerDiv.appendChild(endOfContent); + var event = document.createEvent('CustomEvent'); event.initCustomEvent('textlayerrendered', true, true, { pageNumber: this.pageNumber @@ -1847,7 +1852,41 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() { this.matches = this.convertMatches(this.findController === null ? [] : (this.findController.pageMatches[this.pageIdx] || [])); this.renderMatches(this.matches); - } + }, + + /** + * Fixes text selection: adds additional div where mouse was clicked. + * This reduces flickering of the content if mouse slowly dragged down/up. + * @private + */ + _bindMouse: function TextLayerBuilder_bindMouse() { + var div = this.textLayerDiv; + div.addEventListener('mousedown', function (e) { + var end = div.querySelector('.endOfContent'); + if (!end) { + return; + } + // On non-Firefox browsers, the selection will feel better if the height + // of the endOfContent div will be adjusted to start at mouse click + // location -- this will avoid flickering when selections moves up. + // However it does not work when selection started on empty space. + var adjustTop = e.target !== div; + if (adjustTop) { + var divBounds = div.getBoundingClientRect(); + var r = Math.max(0, (e.pageY - divBounds.top) / divBounds.height); + end.style.top = (r * 100).toFixed(2) + '%'; + } + end.classList.add('active'); + }); + div.addEventListener('mouseup', function (e) { + var end = div.querySelector('.endOfContent'); + if (!end) { + return; + } + end.style.top = ''; + end.classList.remove('active'); + }); + }, }; return TextLayerBuilder; })();