Skip to content

Commit 5467fca

Browse files
committed
Add window resize event
1 parent 3a29123 commit 5467fca

File tree

6 files changed

+22
-1
lines changed

6 files changed

+22
-1
lines changed

src/types/events/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,6 @@ export interface VideomailEvents {
142142
VALIDATING: (params?: ValidatingParams) => void;
143143
// document just became visible
144144
VISIBLE: () => void;
145+
// when window's inner width has changed
146+
WINDOW_RESIZE: () => void;
145147
}

src/util/html/dimensions/useFullWidth.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { Dimension } from "../../../types/dimension";
22

3-
// TODO Implement event listener when viewport width has changed to reconfigure dimensions
43
function useFullWidth(mobileBreakPoint?: number) {
54
if (mobileBreakPoint === undefined) {
65
return undefined;

src/wrappers/container.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ class Container extends Despot {
236236
private initEvents(playerOnly = false) {
237237
this.options.logger.debug(`Container: initEvents (playerOnly = ${playerOnly})`);
238238

239+
window.addEventListener("resize", () => {
240+
this.emit("WINDOW_RESIZE");
241+
});
242+
239243
if (this.options.enableAutoUnload) {
240244
window.addEventListener(
241245
"beforeunload",
@@ -319,6 +323,10 @@ class Container extends Despot {
319323
}
320324
});
321325

326+
this.on("WINDOW_RESIZE", () => {
327+
this.correctDimensions();
328+
});
329+
322330
if (!playerOnly) {
323331
this.on("LOADED_META_DATA", () => {
324332
this.correctDimensions();

src/wrappers/visuals.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ class Visuals extends Despot {
108108
this.removeDimensions();
109109
}
110110
});
111+
112+
this.on("WINDOW_RESIZE", () => {
113+
this.correctDimensions();
114+
});
111115
}
112116
}
113117

src/wrappers/visuals/notifier.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ class Notifier extends Despot {
148148
this.hide();
149149
}
150150
});
151+
152+
this.on("WINDOW_RESIZE", () => {
153+
this.correctNotifierDimensions();
154+
});
151155
}
152156

153157
private correctNotifierDimensions() {

src/wrappers/visuals/recorder.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1414,6 +1414,10 @@ class Recorder extends Despot {
14141414
this.on("SWITCH_FACING_MODE", () => {
14151415
this.switchFacingMode();
14161416
});
1417+
1418+
this.on("WINDOW_RESIZE", () => {
1419+
this.correctDimensions();
1420+
});
14171421
}
14181422

14191423
private buildElement() {

0 commit comments

Comments
 (0)