Add the |location| to the |updateviewarea| UI event
*This patch addresses an issue I stumbled upon while working on rewriting the history implementation.* Currently the `updateviewarea` UI event doesn't include the `location`, and in the event handler in viewer.js we instead reach into `PDFViewer` to retrieve it. Not only does this seem conceptually wrong, it also makes the `updateviewarea` event less useful in general since it's currently only possible to access the `location` if you have a reference to the `PDFViewer`. To me, this simply appears to be an oversight in the implementation, hence this patch which adds `location` to the `updateviewarea` event. It also changes `location` to be a "private" property of `PDFViewer`.
This commit is contained in:
parent
6d2d854f65
commit
ba0eb7fdc6
@ -326,7 +326,7 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
this._currentScale = UNKNOWN_SCALE;
|
this._currentScale = UNKNOWN_SCALE;
|
||||||
this._currentScaleValue = null;
|
this._currentScaleValue = null;
|
||||||
this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
|
this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
|
||||||
this.location = null;
|
this._location = null;
|
||||||
this._pagesRotation = 0;
|
this._pagesRotation = 0;
|
||||||
this._pagesRequests = [];
|
this._pagesRequests = [];
|
||||||
|
|
||||||
@ -374,11 +374,11 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
|
|
||||||
if (!noScroll) {
|
if (!noScroll) {
|
||||||
var page = this._currentPageNumber, dest;
|
var page = this._currentPageNumber, dest;
|
||||||
if (this.location && !IGNORE_CURRENT_POSITION_ON_ZOOM &&
|
if (this._location && !IGNORE_CURRENT_POSITION_ON_ZOOM &&
|
||||||
!(this.isInPresentationMode || this.isChangingPresentationMode)) {
|
!(this.isInPresentationMode || this.isChangingPresentationMode)) {
|
||||||
page = this.location.pageNumber;
|
page = this._location.pageNumber;
|
||||||
dest = [null, { name: 'XYZ' }, this.location.left,
|
dest = [null, { name: 'XYZ' }, this._location.left,
|
||||||
this.location.top, null];
|
this._location.top, null];
|
||||||
}
|
}
|
||||||
this.scrollPageIntoView(page, dest);
|
this.scrollPageIntoView(page, dest);
|
||||||
}
|
}
|
||||||
@ -557,7 +557,7 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
var intTop = Math.round(topLeft[1]);
|
var intTop = Math.round(topLeft[1]);
|
||||||
pdfOpenParams += ',' + intLeft + ',' + intTop;
|
pdfOpenParams += ',' + intLeft + ',' + intTop;
|
||||||
|
|
||||||
this.location = {
|
this._location = {
|
||||||
pageNumber: pageNumber,
|
pageNumber: pageNumber,
|
||||||
scale: normalizedScaleValue,
|
scale: normalizedScaleValue,
|
||||||
top: intTop,
|
top: intTop,
|
||||||
@ -611,6 +611,7 @@ var PDFViewer = (function pdfViewer() {
|
|||||||
|
|
||||||
var event = document.createEvent('UIEvents');
|
var event = document.createEvent('UIEvents');
|
||||||
event.initUIEvent('updateviewarea', true, true, window, 0);
|
event.initUIEvent('updateviewarea', true, true, window, 0);
|
||||||
|
event.location = this._location;
|
||||||
this.container.dispatchEvent(event);
|
this.container.dispatchEvent(event);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1753,12 +1753,11 @@ function updateViewarea() {
|
|||||||
PDFViewerApplication.pdfViewer.update();
|
PDFViewerApplication.pdfViewer.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('updateviewarea', function () {
|
window.addEventListener('updateviewarea', function (evt) {
|
||||||
if (!PDFViewerApplication.initialized) {
|
if (!PDFViewerApplication.initialized) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var location = evt.location;
|
||||||
var location = PDFViewerApplication.pdfViewer.location;
|
|
||||||
|
|
||||||
PDFViewerApplication.store.initializedPromise.then(function() {
|
PDFViewerApplication.store.initializedPromise.then(function() {
|
||||||
PDFViewerApplication.store.setMultiple({
|
PDFViewerApplication.store.setMultiple({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user