Adds pre and post UI control change events.

This commit is contained in:
Yury Delendik 2016-04-29 10:05:04 -05:00
parent 4968ac7cea
commit 4a2c76a34f
2 changed files with 17 additions and 10 deletions

View file

@ -166,23 +166,28 @@ var PDFViewer = (function pdfViewer() {
return;
}
var arg;
if (!(0 < val && val <= this.pagesCount)) {
this.eventBus.dispatch('pagechange', {
arg = {
source: this,
updateInProgress: this.updateInProgress,
pageNumber: this._currentPageNumber,
previousPageNumber: val
});
};
this.eventBus.dispatch('pagechanging', arg);
this.eventBus.dispatch('pagechange', arg);
return;
}
this.eventBus.dispatch('pagechange', {
arg = {
source: this,
updateInProgress: this.updateInProgress,
pageNumber: val,
previousPageNumber: this._currentPageNumber
});
};
this.eventBus.dispatch('pagechanging', arg);
this._currentPageNumber = val;
this.eventBus.dispatch('pagechange', arg);
// Check if the caller is `PDFViewer_update`, to avoid breaking scrolling.
if (this.updateInProgress) {
@ -403,11 +408,13 @@ var PDFViewer = (function pdfViewer() {
_setScaleDispatchEvent: function pdfViewer_setScaleDispatchEvent(
newScale, newValue, preset) {
this.eventBus.dispatch('scalechange', {
var arg = {
source: this,
scale: newScale,
presetValue: preset ? newValue : undefined
});
};
this.eventBus.dispatch('scalechanging', arg);
this.eventBus.dispatch('scalechange', arg);
},
_setScaleUpdatePages: function pdfViewer_setScaleUpdatePages(