|
|
@ -35,6 +35,7 @@ var _pdf_thumbnail_view = require('./pdf_thumbnail_view'); |
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
|
|
|
|
|
|
|
|
|
|
var THUMBNAIL_SCROLL_MARGIN = -19; |
|
|
|
var THUMBNAIL_SCROLL_MARGIN = -19; |
|
|
|
|
|
|
|
var THUMBNAIL_SELECTED_CLASS = 'selected'; |
|
|
|
|
|
|
|
|
|
|
|
var PDFThumbnailViewer = function () { |
|
|
|
var PDFThumbnailViewer = function () { |
|
|
|
function PDFThumbnailViewer(_ref) { |
|
|
|
function PDFThumbnailViewer(_ref) { |
|
|
@ -71,14 +72,19 @@ var PDFThumbnailViewer = function () { |
|
|
|
} |
|
|
|
} |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
key: 'scrollThumbnailIntoView', |
|
|
|
key: 'scrollThumbnailIntoView', |
|
|
|
value: function scrollThumbnailIntoView(page) { |
|
|
|
value: function scrollThumbnailIntoView(pageNumber) { |
|
|
|
var selected = document.querySelector('.thumbnail.selected'); |
|
|
|
if (!this.pdfDocument) { |
|
|
|
if (selected) { |
|
|
|
return; |
|
|
|
selected.classList.remove('selected'); |
|
|
|
} |
|
|
|
|
|
|
|
var thumbnailView = this._thumbnails[pageNumber - 1]; |
|
|
|
|
|
|
|
if (!thumbnailView) { |
|
|
|
|
|
|
|
console.error('scrollThumbnailIntoView: Invalid "pageNumber" parameter.'); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
var thumbnail = document.querySelector('div.thumbnail[data-page-number="' + page + '"]'); |
|
|
|
if (pageNumber !== this._currentPageNumber) { |
|
|
|
if (thumbnail) { |
|
|
|
var prevThumbnailView = this._thumbnails[this._currentPageNumber - 1]; |
|
|
|
thumbnail.classList.add('selected'); |
|
|
|
prevThumbnailView.div.classList.remove(THUMBNAIL_SELECTED_CLASS); |
|
|
|
|
|
|
|
thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS); |
|
|
|
} |
|
|
|
} |
|
|
|
var visibleThumbs = this._getVisibleThumbs(); |
|
|
|
var visibleThumbs = this._getVisibleThumbs(); |
|
|
|
var numVisibleThumbs = visibleThumbs.views.length; |
|
|
|
var numVisibleThumbs = visibleThumbs.views.length; |
|
|
@ -86,11 +92,11 @@ var PDFThumbnailViewer = function () { |
|
|
|
var first = visibleThumbs.first.id; |
|
|
|
var first = visibleThumbs.first.id; |
|
|
|
var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first; |
|
|
|
var last = numVisibleThumbs > 1 ? visibleThumbs.last.id : first; |
|
|
|
var shouldScroll = false; |
|
|
|
var shouldScroll = false; |
|
|
|
if (page <= first || page >= last) { |
|
|
|
if (pageNumber <= first || pageNumber >= last) { |
|
|
|
shouldScroll = true; |
|
|
|
shouldScroll = true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
visibleThumbs.views.some(function (view) { |
|
|
|
visibleThumbs.views.some(function (view) { |
|
|
|
if (view.id !== page) { |
|
|
|
if (view.id !== pageNumber) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
shouldScroll = view.percent < 100; |
|
|
|
shouldScroll = view.percent < 100; |
|
|
@ -98,9 +104,10 @@ var PDFThumbnailViewer = function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
if (shouldScroll) { |
|
|
|
if (shouldScroll) { |
|
|
|
(0, _ui_utils.scrollIntoView)(thumbnail, { top: THUMBNAIL_SCROLL_MARGIN }); |
|
|
|
(0, _ui_utils.scrollIntoView)(thumbnailView.div, { top: THUMBNAIL_SCROLL_MARGIN }); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this._currentPageNumber = pageNumber; |
|
|
|
} |
|
|
|
} |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
key: 'cleanup', |
|
|
|
key: 'cleanup', |
|
|
@ -111,6 +118,7 @@ var PDFThumbnailViewer = function () { |
|
|
|
key: '_resetView', |
|
|
|
key: '_resetView', |
|
|
|
value: function _resetView() { |
|
|
|
value: function _resetView() { |
|
|
|
this._thumbnails = []; |
|
|
|
this._thumbnails = []; |
|
|
|
|
|
|
|
this._currentPageNumber = 1; |
|
|
|
this._pageLabels = null; |
|
|
|
this._pageLabels = null; |
|
|
|
this._pagesRotation = 0; |
|
|
|
this._pagesRotation = 0; |
|
|
|
this._pagesRequests = []; |
|
|
|
this._pagesRequests = []; |
|
|
@ -144,6 +152,8 @@ var PDFThumbnailViewer = function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
_this._thumbnails.push(thumbnail); |
|
|
|
_this._thumbnails.push(thumbnail); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var thumbnailView = _this._thumbnails[_this._currentPageNumber - 1]; |
|
|
|
|
|
|
|
thumbnailView.div.classList.add(THUMBNAIL_SELECTED_CLASS); |
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
console.error('Unable to initialize thumbnail viewer', reason); |
|
|
|
console.error('Unable to initialize thumbnail viewer', reason); |
|
|
|
}); |
|
|
|
}); |
|
|
|