Merge pull request #11433 from wojtekmaj/pdf-thumbnail-viewer-const
Use const in pdf_thumbnail_viewer.js
This commit is contained in:
commit
0f641e66cc
@ -12,6 +12,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
/* eslint no-var: error, prefer-const: error */
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getVisibleElements, isValidRotation, NullL10n, scrollIntoView, watchScroll
|
getVisibleElements, isValidRotation, NullL10n, scrollIntoView, watchScroll
|
||||||
@ -85,14 +86,14 @@ class PDFThumbnailViewer {
|
|||||||
// ... and add the highlight to the new thumbnail.
|
// ... and add the highlight to the new thumbnail.
|
||||||
thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
|
thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS);
|
||||||
}
|
}
|
||||||
let visibleThumbs = this._getVisibleThumbs();
|
const visibleThumbs = this._getVisibleThumbs();
|
||||||
let numVisibleThumbs = visibleThumbs.views.length;
|
const numVisibleThumbs = visibleThumbs.views.length;
|
||||||
|
|
||||||
// If the thumbnail isn't currently visible, scroll it into view.
|
// If the thumbnail isn't currently visible, scroll it into view.
|
||||||
if (numVisibleThumbs > 0) {
|
if (numVisibleThumbs > 0) {
|
||||||
let first = visibleThumbs.first.id;
|
const first = visibleThumbs.first.id;
|
||||||
// Account for only one thumbnail being visible.
|
// Account for only one thumbnail being visible.
|
||||||
let last = (numVisibleThumbs > 1 ? visibleThumbs.last.id : first);
|
const last = (numVisibleThumbs > 1 ? visibleThumbs.last.id : first);
|
||||||
|
|
||||||
let shouldScroll = false;
|
let shouldScroll = false;
|
||||||
if (pageNumber <= first || pageNumber >= last) {
|
if (pageNumber <= first || pageNumber >= last) {
|
||||||
@ -165,10 +166,10 @@ class PDFThumbnailViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pdfDocument.getPage(1).then((firstPdfPage) => {
|
pdfDocument.getPage(1).then((firstPdfPage) => {
|
||||||
let pagesCount = pdfDocument.numPages;
|
const pagesCount = pdfDocument.numPages;
|
||||||
const viewport = firstPdfPage.getViewport({ scale: 1, });
|
const viewport = firstPdfPage.getViewport({ scale: 1, });
|
||||||
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
for (let pageNum = 1; pageNum <= pagesCount; ++pageNum) {
|
||||||
let thumbnail = new PDFThumbnailView({
|
const thumbnail = new PDFThumbnailView({
|
||||||
container: this.container,
|
container: this.container,
|
||||||
id: pageNum,
|
id: pageNum,
|
||||||
defaultViewport: viewport.clone(),
|
defaultViewport: viewport.clone(),
|
||||||
@ -224,7 +225,7 @@ class PDFThumbnailViewer {
|
|||||||
}
|
}
|
||||||
// Update all the `PDFThumbnailView` instances.
|
// Update all the `PDFThumbnailView` instances.
|
||||||
for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
|
for (let i = 0, ii = this._thumbnails.length; i < ii; i++) {
|
||||||
let label = this._pageLabels && this._pageLabels[i];
|
const label = this._pageLabels && this._pageLabels[i];
|
||||||
this._thumbnails[i].setPageLabel(label);
|
this._thumbnails[i].setPageLabel(label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -257,10 +258,10 @@ class PDFThumbnailViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
forceRendering() {
|
forceRendering() {
|
||||||
let visibleThumbs = this._getVisibleThumbs();
|
const visibleThumbs = this._getVisibleThumbs();
|
||||||
let thumbView = this.renderingQueue.getHighestPriority(visibleThumbs,
|
const thumbView = this.renderingQueue.getHighestPriority(visibleThumbs,
|
||||||
this._thumbnails,
|
this._thumbnails,
|
||||||
this.scroll.down);
|
this.scroll.down);
|
||||||
if (thumbView) {
|
if (thumbView) {
|
||||||
this._ensurePdfPageLoaded(thumbView).then(() => {
|
this._ensurePdfPageLoaded(thumbView).then(() => {
|
||||||
this.renderingQueue.renderView(thumbView);
|
this.renderingQueue.renderView(thumbView);
|
||||||
|
Loading…
Reference in New Issue
Block a user