1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var getWindow_1 = require("./dom/getWindow");
|
4 | var keyboard_1 = require("./keyboard");
|
5 | var setFocusVisibility_1 = require("./setFocusVisibility");
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | function initializeFocusRects(window) {
|
23 | var _a;
|
24 | var win = (window || getWindow_1.getWindow());
|
25 | if (!win || ((_a = win.FabricConfig) === null || _a === void 0 ? void 0 : _a.disableFocusRects) === true) {
|
26 | return;
|
27 | }
|
28 | if (!win.__hasInitializeFocusRects__) {
|
29 | win.__hasInitializeFocusRects__ = true;
|
30 | win.addEventListener('mousedown', _onMouseDown, true);
|
31 | win.addEventListener('pointerdown', _onPointerDown, true);
|
32 | win.addEventListener('keydown', _onKeyDown, true);
|
33 | }
|
34 | }
|
35 | exports.initializeFocusRects = initializeFocusRects;
|
36 | function _onMouseDown(ev) {
|
37 | setFocusVisibility_1.setFocusVisibility(false, ev.target);
|
38 | }
|
39 | function _onPointerDown(ev) {
|
40 | if (ev.pointerType !== 'mouse') {
|
41 | setFocusVisibility_1.setFocusVisibility(false, ev.target);
|
42 | }
|
43 | }
|
44 | function _onKeyDown(ev) {
|
45 |
|
46 | keyboard_1.isDirectionalKeyCode(ev.which) && setFocusVisibility_1.setFocusVisibility(true, ev.target);
|
47 | }
|
48 |
|
\ | No newline at end of file |