mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Include the state
in the "presentationmodechanged" event, and remove the separate active
/switchInProgress
properties
Given that we already have a `PresentationModeState`-enumeration, we should use that with the "presentationmodechanged" event rather than including separate properties. Note that this new behaviour, of including an enumeration-value in the event, is consistent with lots of other existing viewer-events. To hopefully avoid issues in custom implementations of the default viewer, any attempt to access the removed properties will now throw.
This commit is contained in:
parent
50303fc8f4
commit
c185061757
5 changed files with 55 additions and 31 deletions
|
@ -14,6 +14,7 @@
|
|||
*/
|
||||
|
||||
import { GrabToPan } from "./grab_to_pan.js";
|
||||
import { PresentationModeState } from "./ui_utils.js";
|
||||
|
||||
const CursorTool = {
|
||||
SELECT: 0, // The default value.
|
||||
|
@ -127,21 +128,23 @@ class PDFCursorTools {
|
|||
});
|
||||
|
||||
this.eventBus._on("presentationmodechanged", evt => {
|
||||
if (evt.switchInProgress) {
|
||||
return;
|
||||
}
|
||||
let previouslyActive;
|
||||
switch (evt.state) {
|
||||
case PresentationModeState.CHANGING:
|
||||
break;
|
||||
case PresentationModeState.FULLSCREEN: {
|
||||
const previouslyActive = this.active;
|
||||
|
||||
if (evt.active) {
|
||||
previouslyActive = this.active;
|
||||
this.switchTool(CursorTool.SELECT);
|
||||
this.activeBeforePresentationMode = previouslyActive;
|
||||
break;
|
||||
}
|
||||
case PresentationModeState.NORMAL: {
|
||||
const previouslyActive = this.activeBeforePresentationMode;
|
||||
|
||||
this.switchTool(CursorTool.SELECT);
|
||||
this.activeBeforePresentationMode = previouslyActive;
|
||||
} else {
|
||||
previouslyActive = this.activeBeforePresentationMode;
|
||||
|
||||
this.activeBeforePresentationMode = null;
|
||||
this.switchTool(previouslyActive);
|
||||
this.activeBeforePresentationMode = null;
|
||||
this.switchTool(previouslyActive);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue