mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
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
1 changed files with 6 additions and 0 deletions
|
@ -460,6 +460,8 @@ class BaseViewer {
|
|||
*/
|
||||
setDocument(pdfDocument) {
|
||||
if (this.pdfDocument) {
|
||||
this.eventBus.dispatch("pagesdestroy", { source: this });
|
||||
|
||||
this._cancelRendering();
|
||||
this._resetView();
|
||||
|
||||
|
@ -1555,6 +1557,10 @@ class BaseViewer {
|
|||
eventBus._on("pagesinit", () => {
|
||||
dispatchPageOpen(this._currentPageNumber);
|
||||
});
|
||||
|
||||
eventBus._on("pagesdestroy", () => {
|
||||
dispatchPageClose(this._currentPageNumber);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue