Merge pull request #12788 from Snuffleupagus/presentationmodechanged-state
Include the `state` in the "presentationmodechanged" event, and remove the separate `active`/`switchInProgress` properties
This commit is contained in:
commit
3e34281e3b
11
web/app.js
11
web/app.js
@ -29,7 +29,6 @@ import {
|
|||||||
noContextMenuHandler,
|
noContextMenuHandler,
|
||||||
normalizeWheelEventDirection,
|
normalizeWheelEventDirection,
|
||||||
parseQueryString,
|
parseQueryString,
|
||||||
PresentationModeState,
|
|
||||||
ProgressBar,
|
ProgressBar,
|
||||||
RendererType,
|
RendererType,
|
||||||
ScrollMode,
|
ScrollMode,
|
||||||
@ -2620,14 +2619,8 @@ function webViewerNamedAction(evt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function webViewerPresentationModeChanged({ active, switchInProgress }) {
|
function webViewerPresentationModeChanged(evt) {
|
||||||
let state = PresentationModeState.NORMAL;
|
PDFViewerApplication.pdfViewer.presentationModeState = evt.state;
|
||||||
if (switchInProgress) {
|
|
||||||
state = PresentationModeState.CHANGING;
|
|
||||||
} else if (active) {
|
|
||||||
state = PresentationModeState.FULLSCREEN;
|
|
||||||
}
|
|
||||||
PDFViewerApplication.pdfViewer.presentationModeState = state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function webViewerSidebarViewChanged(evt) {
|
function webViewerSidebarViewChanged(evt) {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { GrabToPan } from "./grab_to_pan.js";
|
import { GrabToPan } from "./grab_to_pan.js";
|
||||||
|
import { PresentationModeState } from "./ui_utils.js";
|
||||||
|
|
||||||
const CursorTool = {
|
const CursorTool = {
|
||||||
SELECT: 0, // The default value.
|
SELECT: 0, // The default value.
|
||||||
@ -127,21 +128,23 @@ class PDFCursorTools {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.eventBus._on("presentationmodechanged", evt => {
|
this.eventBus._on("presentationmodechanged", evt => {
|
||||||
if (evt.switchInProgress) {
|
switch (evt.state) {
|
||||||
return;
|
case PresentationModeState.CHANGING:
|
||||||
}
|
break;
|
||||||
let previouslyActive;
|
case PresentationModeState.FULLSCREEN: {
|
||||||
|
const previouslyActive = this.active;
|
||||||
|
|
||||||
if (evt.active) {
|
this.switchTool(CursorTool.SELECT);
|
||||||
previouslyActive = this.active;
|
this.activeBeforePresentationMode = previouslyActive;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PresentationModeState.NORMAL: {
|
||||||
|
const previouslyActive = this.activeBeforePresentationMode;
|
||||||
|
|
||||||
this.switchTool(CursorTool.SELECT);
|
this.activeBeforePresentationMode = null;
|
||||||
this.activeBeforePresentationMode = previouslyActive;
|
this.switchTool(previouslyActive);
|
||||||
} else {
|
break;
|
||||||
previouslyActive = this.activeBeforePresentationMode;
|
}
|
||||||
|
|
||||||
this.activeBeforePresentationMode = null;
|
|
||||||
this.switchTool(previouslyActive);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
import {
|
import {
|
||||||
isValidRotation,
|
isValidRotation,
|
||||||
parseQueryString,
|
parseQueryString,
|
||||||
|
PresentationModeState,
|
||||||
waitOnEventOrTimeout,
|
waitOnEventOrTimeout,
|
||||||
} from "./ui_utils.js";
|
} from "./ui_utils.js";
|
||||||
|
|
||||||
@ -69,7 +70,8 @@ class PDFHistory {
|
|||||||
// Ensure that we don't miss either a 'presentationmodechanged' or a
|
// Ensure that we don't miss either a 'presentationmodechanged' or a
|
||||||
// 'pagesinit' event, by registering the listeners immediately.
|
// 'pagesinit' event, by registering the listeners immediately.
|
||||||
this.eventBus._on("presentationmodechanged", evt => {
|
this.eventBus._on("presentationmodechanged", evt => {
|
||||||
this._isViewerInPresentationMode = evt.active || evt.switchInProgress;
|
this._isViewerInPresentationMode =
|
||||||
|
evt.state !== PresentationModeState.NORMAL;
|
||||||
});
|
});
|
||||||
this.eventBus._on("pagesinit", () => {
|
this.eventBus._on("pagesinit", () => {
|
||||||
this._isPagesLoaded = false;
|
this._isPagesLoaded = false;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { normalizeWheelEventDelta } from "./ui_utils.js";
|
import { normalizeWheelEventDelta, PresentationModeState } from "./ui_utils.js";
|
||||||
|
|
||||||
const DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500; // in ms
|
const DELAY_BEFORE_RESETTING_SWITCH_IN_PROGRESS = 1500; // in ms
|
||||||
const DELAY_BEFORE_HIDING_CONTROLS = 3000; // in ms
|
const DELAY_BEFORE_HIDING_CONTROLS = 3000; // in ms
|
||||||
@ -183,11 +183,34 @@ class PDFPresentationMode {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_notifyStateChange() {
|
_notifyStateChange() {
|
||||||
this.eventBus.dispatch("presentationmodechanged", {
|
let state = PresentationModeState.NORMAL;
|
||||||
source: this,
|
if (this.switchInProgress) {
|
||||||
active: this.active,
|
state = PresentationModeState.CHANGING;
|
||||||
switchInProgress: !!this.switchInProgress,
|
} else if (this.active) {
|
||||||
});
|
state = PresentationModeState.FULLSCREEN;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
||||||
|
this.eventBus.dispatch("presentationmodechanged", {
|
||||||
|
source: this,
|
||||||
|
state,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.eventBus.dispatch("presentationmodechanged", {
|
||||||
|
source: this,
|
||||||
|
state,
|
||||||
|
get active() {
|
||||||
|
throw new Error(
|
||||||
|
"Deprecated parameter: `active`, please use `state` instead."
|
||||||
|
);
|
||||||
|
},
|
||||||
|
get switchInProgress() {
|
||||||
|
throw new Error(
|
||||||
|
"Deprecated parameter: `switchInProgress`, please use `state` instead."
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { NullL10n } from "./ui_utils.js";
|
import { NullL10n, PresentationModeState } from "./ui_utils.js";
|
||||||
import { RenderingStates } from "./pdf_rendering_queue.js";
|
import { RenderingStates } from "./pdf_rendering_queue.js";
|
||||||
|
|
||||||
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
const UI_NOTIFICATION_CLASS = "pdfSidebarNotification";
|
||||||
@ -491,7 +491,10 @@ class PDFSidebar {
|
|||||||
|
|
||||||
// Update the thumbnailViewer, if visible, when exiting presentation mode.
|
// Update the thumbnailViewer, if visible, when exiting presentation mode.
|
||||||
this.eventBus._on("presentationmodechanged", evt => {
|
this.eventBus._on("presentationmodechanged", evt => {
|
||||||
if (!evt.active && !evt.switchInProgress && this.isThumbnailViewVisible) {
|
if (
|
||||||
|
evt.state === PresentationModeState.NORMAL &&
|
||||||
|
this.isThumbnailViewVisible
|
||||||
|
) {
|
||||||
this._updateThumbnailViewer();
|
this._updateThumbnailViewer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user