mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-09 17:55:37 +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) {
|
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…
Add table
Add a link
Reference in a new issue