Add a new "pagesdestroy" event, dispatched *before* the BaseViewer
removes an existing document
This new event essentially mirrors the existing "pagesinit" event, and will allow e.g. a custom implementation of the viewer to be notified before the current PDF document is removed from the viewer. By using this new event, we're thus able to dispatch a "pageclose" event for JavaScript actions when closing the existing document.
This commit is contained in:
parent
2a83c965e8
commit
0e69973d71
@ -460,6 +460,8 @@ class BaseViewer {
|
|||||||
*/
|
*/
|
||||||
setDocument(pdfDocument) {
|
setDocument(pdfDocument) {
|
||||||
if (this.pdfDocument) {
|
if (this.pdfDocument) {
|
||||||
|
this.eventBus.dispatch("pagesdestroy", { source: this });
|
||||||
|
|
||||||
this._cancelRendering();
|
this._cancelRendering();
|
||||||
this._resetView();
|
this._resetView();
|
||||||
|
|
||||||
@ -1555,6 +1557,10 @@ class BaseViewer {
|
|||||||
eventBus._on("pagesinit", () => {
|
eventBus._on("pagesinit", () => {
|
||||||
dispatchPageOpen(this._currentPageNumber);
|
dispatchPageOpen(this._currentPageNumber);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
eventBus._on("pagesdestroy", () => {
|
||||||
|
dispatchPageClose(this._currentPageNumber);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user