inviton-powerduck 0.0.121 → 0.0.122
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import { arrayRemove } from '../../../common/utils/array-remove';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
if ((window as any).__powerduckBreakpointHandler == null) {
|
|
4
|
+
(window as any).__powerduckBreakpointHandler = {
|
|
5
|
+
_breakpointsBound: false,
|
|
6
|
+
_handlers: [],
|
|
7
|
+
};
|
|
8
|
+
}
|
|
3
9
|
|
|
4
10
|
export class BreakpointHandler {
|
|
5
|
-
private static
|
|
11
|
+
private static get handlers() {
|
|
12
|
+
return (window as any).__powerduckBreakpointHandler._handlers;
|
|
13
|
+
}
|
|
6
14
|
|
|
7
15
|
static addResizeHandler(handler: () => any) {
|
|
8
16
|
BreakpointHandler.bindResizeHandler();
|
|
9
|
-
BreakpointHandler.
|
|
17
|
+
BreakpointHandler.handlers.push(handler);
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
static removeResizeHandler(handler: () => any) {
|
|
13
|
-
arrayRemove(BreakpointHandler.
|
|
21
|
+
arrayRemove(BreakpointHandler.handlers, handler);
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
static bindResizeHandler() {
|
|
17
|
-
if (
|
|
25
|
+
if ((window as any).__powerduckBreakpointHandler._breakpointsBound == true) {
|
|
18
26
|
return;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
|
-
|
|
29
|
+
(window as any).__powerduckBreakpointHandler._breakpointsBound = true;
|
|
22
30
|
window.addEventListener('resize', BreakpointHandler.onWindowHasResized);
|
|
23
31
|
BreakpointHandler.onWindowHasResized();
|
|
24
32
|
}
|
|
@@ -57,7 +65,7 @@ export class BreakpointHandler {
|
|
|
57
65
|
}
|
|
58
66
|
|
|
59
67
|
private static onWindowHasResized() {
|
|
60
|
-
for (const handler of BreakpointHandler.
|
|
68
|
+
for (const handler of BreakpointHandler.handlers) {
|
|
61
69
|
try {
|
|
62
70
|
handler();
|
|
63
71
|
} catch (error) {
|