|
|
@ -138,7 +138,6 @@ var PDFViewer = (function pdfViewer() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this)); |
|
|
|
this.scroll = watchScroll(this.container, this._scrollUpdate.bind(this)); |
|
|
|
this.updateInProgress = false; |
|
|
|
|
|
|
|
this.presentationModeState = PresentationModeState.UNKNOWN; |
|
|
|
this.presentationModeState = PresentationModeState.UNKNOWN; |
|
|
|
this._resetView(); |
|
|
|
this._resetView(); |
|
|
|
|
|
|
|
|
|
|
@ -165,12 +164,19 @@ var PDFViewer = (function pdfViewer() { |
|
|
|
this._currentPageNumber = val; |
|
|
|
this._currentPageNumber = val; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
this._setCurrentPageNumber(val); |
|
|
|
|
|
|
|
// The intent can be to just reset a scroll position and/or scale.
|
|
|
|
|
|
|
|
this._resetCurrentPageView(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_setCurrentPageNumber: function pdfViewer_setCurrentPageNumber(val) { |
|
|
|
|
|
|
|
if (this._currentPageNumber === val) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
var arg; |
|
|
|
var arg; |
|
|
|
if (!(0 < val && val <= this.pagesCount)) { |
|
|
|
if (!(0 < val && val <= this.pagesCount)) { |
|
|
|
arg = { |
|
|
|
arg = { |
|
|
|
source: this, |
|
|
|
source: this, |
|
|
|
updateInProgress: this.updateInProgress, |
|
|
|
|
|
|
|
pageNumber: this._currentPageNumber, |
|
|
|
pageNumber: this._currentPageNumber, |
|
|
|
previousPageNumber: val |
|
|
|
previousPageNumber: val |
|
|
|
}; |
|
|
|
}; |
|
|
@ -181,19 +187,12 @@ var PDFViewer = (function pdfViewer() { |
|
|
|
|
|
|
|
|
|
|
|
arg = { |
|
|
|
arg = { |
|
|
|
source: this, |
|
|
|
source: this, |
|
|
|
updateInProgress: this.updateInProgress, |
|
|
|
|
|
|
|
pageNumber: val, |
|
|
|
pageNumber: val, |
|
|
|
previousPageNumber: this._currentPageNumber |
|
|
|
previousPageNumber: this._currentPageNumber |
|
|
|
}; |
|
|
|
}; |
|
|
|
this.eventBus.dispatch('pagechanging', arg); |
|
|
|
|
|
|
|
this._currentPageNumber = val; |
|
|
|
this._currentPageNumber = val; |
|
|
|
|
|
|
|
this.eventBus.dispatch('pagechanging', arg); |
|
|
|
this.eventBus.dispatch('pagechange', arg); |
|
|
|
this.eventBus.dispatch('pagechange', arg); |
|
|
|
|
|
|
|
|
|
|
|
// Check if the caller is `PDFViewer_update`, to avoid breaking scrolling.
|
|
|
|
|
|
|
|
if (this.updateInProgress) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.scrollPageIntoView(val); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -499,6 +498,19 @@ var PDFViewer = (function pdfViewer() { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Refreshes page view: scrolls to the current page and updates the scale. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
_resetCurrentPageView: function () { |
|
|
|
|
|
|
|
if (this.isInPresentationMode) { |
|
|
|
|
|
|
|
// Fixes the case when PDF has different page sizes.
|
|
|
|
|
|
|
|
this._setScale(this._currentScaleValue, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pageView = this._pages[this._currentPageNumber - 1]; |
|
|
|
|
|
|
|
scrollIntoView(pageView.div); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Scrolls page into view. |
|
|
|
* Scrolls page into view. |
|
|
|
* @param {number} pageNumber |
|
|
|
* @param {number} pageNumber |
|
|
@ -511,23 +523,13 @@ var PDFViewer = (function pdfViewer() { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var pageView = this._pages[pageNumber - 1]; |
|
|
|
if (this.isInPresentationMode || !dest) { |
|
|
|
|
|
|
|
this._setCurrentPageNumber(pageNumber); |
|
|
|
if (this.isInPresentationMode) { |
|
|
|
this._resetCurrentPageView(); |
|
|
|
if (this._currentPageNumber !== pageView.id) { |
|
|
|
|
|
|
|
// Avoid breaking getVisiblePages in presentation mode.
|
|
|
|
|
|
|
|
this.currentPageNumber = pageView.id; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
dest = null; |
|
|
|
|
|
|
|
// Fixes the case when PDF has different page sizes.
|
|
|
|
|
|
|
|
this._setScale(this._currentScaleValue, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!dest) { |
|
|
|
|
|
|
|
scrollIntoView(pageView.div); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pageView = this._pages[pageNumber - 1]; |
|
|
|
var x = 0, y = 0; |
|
|
|
var x = 0, y = 0; |
|
|
|
var width = 0, height = 0, widthScale, heightScale; |
|
|
|
var width = 0, height = 0, widthScale, heightScale; |
|
|
|
var changeOrientation = (pageView.rotation % 180 === 0 ? false : true); |
|
|
|
var changeOrientation = (pageView.rotation % 180 === 0 ? false : true); |
|
|
@ -644,8 +646,6 @@ var PDFViewer = (function pdfViewer() { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.updateInProgress = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, |
|
|
|
var suggestedCacheSize = Math.max(DEFAULT_CACHE_SIZE, |
|
|
|
2 * visiblePages.length + 1); |
|
|
|
2 * visiblePages.length + 1); |
|
|
|
this._buffer.resize(suggestedCacheSize); |
|
|
|
this._buffer.resize(suggestedCacheSize); |
|
|
@ -673,13 +673,11 @@ var PDFViewer = (function pdfViewer() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!this.isInPresentationMode) { |
|
|
|
if (!this.isInPresentationMode) { |
|
|
|
this.currentPageNumber = currentId; |
|
|
|
this._setCurrentPageNumber(currentId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this._updateLocation(firstPage); |
|
|
|
this._updateLocation(firstPage); |
|
|
|
|
|
|
|
|
|
|
|
this.updateInProgress = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.eventBus.dispatch('updateviewarea', { |
|
|
|
this.eventBus.dispatch('updateviewarea', { |
|
|
|
source: this, |
|
|
|
source: this, |
|
|
|
location: this._location |
|
|
|
location: this._location |
|
|
|