@enact/spotlight 3.4.9-experimental-3 → 3.4.9-experimental-7
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.
- package/{build/Accelerator → Accelerator}/Accelerator.d.ts +0 -0
- package/Accelerator/Accelerator.js +149 -156
- package/CHANGELOG.md +22 -0
- package/{build/Pause → Pause}/Pause.d.ts +0 -0
- package/Pause/Pause.js +102 -80
- package/Pause/tests/Pause-specs.js +65 -97
- package/SpotlightContainerDecorator/SpotlightContainer.js +175 -140
- package/{build/SpotlightContainerDecorator → SpotlightContainerDecorator}/SpotlightContainerDecorator.d.ts +0 -0
- package/SpotlightContainerDecorator/SpotlightContainerDecorator.js +222 -176
- package/SpotlightContainerDecorator/tests/Element.prototype.closest.js +44 -40
- package/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +221 -210
- package/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +150 -243
- package/SpotlightContainerDecorator/useSpotlightContainer.js +47 -28
- package/{build/SpotlightRootDecorator → SpotlightRootDecorator}/SpotlightRootDecorator.d.ts +0 -0
- package/SpotlightRootDecorator/SpotlightRootDecorator.js +206 -111
- package/{build/Spottable → Spottable}/Spottable.d.ts +0 -0
- package/Spottable/Spottable.js +448 -410
- package/Spottable/tests/Spottable-specs.js +90 -117
- package/package.json +3 -2
- package/src/container.js +718 -653
- package/src/navigate.js +406 -491
- package/src/pointer.js +86 -78
- package/{build/src → src}/spotlight.d.ts +0 -0
- package/src/spotlight.js +846 -885
- package/src/target.js +448 -474
- package/src/tests/container-specs.js +643 -1251
- package/src/tests/navigate-specs.js +77 -134
- package/src/tests/pointer-specs.js +126 -182
- package/src/tests/spotlight-specs.js +103 -133
- package/src/tests/target-specs.js +597 -960
- package/src/tests/utils.js +89 -67
- package/src/utils.js +155 -158
- package/build/Accelerator/Accelerator.js +0 -162
- package/build/Accelerator/package.json +0 -3
- package/build/CHANGELOG.md +0 -838
- package/build/Pause/Pause.js +0 -164
- package/build/Pause/package.json +0 -3
- package/build/Pause/tests/Pause-specs.js +0 -65
- package/build/README.md +0 -61
- package/build/SpotlightContainerDecorator/SpotlightContainer.js +0 -176
- package/build/SpotlightContainerDecorator/SpotlightContainerDecorator.js +0 -282
- package/build/SpotlightContainerDecorator/package.json +0 -3
- package/build/SpotlightContainerDecorator/tests/Element.prototype.closest.js +0 -45
- package/build/SpotlightContainerDecorator/tests/SpotlightContainerDecorator-specs.js +0 -221
- package/build/SpotlightContainerDecorator/tests/useSpotlightContainer-specs.js +0 -160
- package/build/SpotlightContainerDecorator/useSpotlightContainer.js +0 -133
- package/build/SpotlightRootDecorator/SpotlightRootDecorator.js +0 -189
- package/build/SpotlightRootDecorator/package.json +0 -3
- package/build/Spottable/Spottable.js +0 -491
- package/build/Spottable/package.json +0 -3
- package/build/Spottable/tests/Spottable-specs.js +0 -90
- package/build/package-lock.json +0 -229
- package/build/package.json +0 -28
- package/build/src/container.js +0 -1201
- package/build/src/navigate.js +0 -419
- package/build/src/pointer.js +0 -183
- package/build/src/spotlight.js +0 -896
- package/build/src/target.js +0 -507
- package/build/src/tests/container-specs.js +0 -653
- package/build/src/tests/navigate-specs.js +0 -87
- package/build/src/tests/pointer-specs.js +0 -130
- package/build/src/tests/spotlight-specs.js +0 -112
- package/build/src/tests/target-specs.js +0 -614
- package/build/src/tests/utils.js +0 -104
- package/build/src/utils.js +0 -180
- package/build/styles/debug.less +0 -97
- package/build/styles/mixins.less +0 -63
- package/docs/index.md +0 -364
package/src/target.js
CHANGED
|
@@ -1,415 +1,382 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getNavigableTarget = getNavigableTarget;
|
|
7
|
+
exports.getTargetByContainer = getTargetByContainer;
|
|
8
|
+
exports.getTargetByDirectionFromElement = getTargetByDirectionFromElement;
|
|
9
|
+
exports.getTargetByDirectionFromPosition = getTargetByDirectionFromPosition;
|
|
10
|
+
exports.getTargetBySelector = getTargetBySelector;
|
|
11
|
+
exports.isFocusable = isFocusable;
|
|
12
|
+
exports.getNearestTargetFromPosition = void 0;
|
|
13
|
+
|
|
14
|
+
var _clamp = _interopRequireDefault(require("ramda/src/clamp"));
|
|
15
|
+
|
|
16
|
+
var _last = _interopRequireDefault(require("ramda/src/last"));
|
|
17
|
+
|
|
18
|
+
var _container = require("./container");
|
|
19
|
+
|
|
20
|
+
var _navigate = _interopRequireDefault(require("./navigate"));
|
|
21
|
+
|
|
22
|
+
var _utils = require("./utils");
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
+
|
|
26
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
+
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
29
|
+
|
|
30
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
31
|
+
|
|
32
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
33
|
+
|
|
34
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
35
|
+
|
|
36
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
|
+
|
|
38
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
39
|
+
|
|
40
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
41
|
+
|
|
42
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
43
|
+
|
|
44
|
+
function isFocusable(elem) {
|
|
45
|
+
var containers = (0, _container.getContainersForNode)(elem);
|
|
46
|
+
var verifySelector = true;
|
|
47
|
+
|
|
48
|
+
for (var i = containers.length - 1; i >= 0; i--) {
|
|
49
|
+
var containerId = containers[i];
|
|
50
|
+
|
|
51
|
+
if (!(0, _container.isNavigable)(elem, containerId, verifySelector)) {
|
|
52
|
+
return false;
|
|
53
|
+
} // only verify selector for the first (immediate ancestor) container
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
verifySelector = false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return true;
|
|
45
60
|
}
|
|
46
61
|
|
|
47
|
-
function getContainersToSearch
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
function getContainersToSearch(containerId) {
|
|
63
|
+
var range = [];
|
|
64
|
+
|
|
65
|
+
var addRange = function addRange(id) {
|
|
66
|
+
var config = (0, _container.getContainerConfig)(id);
|
|
67
|
+
|
|
68
|
+
if (id && range.indexOf(id) < 0 && config && !config.selectorDisabled) {
|
|
69
|
+
range.push(id);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (containerId) {
|
|
74
|
+
addRange(containerId);
|
|
75
|
+
} else {
|
|
76
|
+
addRange((0, _container.getDefaultContainer)());
|
|
77
|
+
addRange((0, _container.getLastContainer)());
|
|
78
|
+
|
|
79
|
+
_toConsumableArray((0, _container.getAllContainerIds)()).map(addRange);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return range;
|
|
66
83
|
}
|
|
67
84
|
|
|
68
|
-
function getTargetByContainer
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, null);
|
|
85
|
+
function getTargetByContainer(containerId, enterTo) {
|
|
86
|
+
return getContainersToSearch(containerId).reduce(function (next, id) {
|
|
87
|
+
return next || (0, _container.getContainerFocusTarget)(id, enterTo);
|
|
88
|
+
}, null);
|
|
73
89
|
}
|
|
74
90
|
|
|
75
|
-
function getTargetBySelector
|
|
76
|
-
|
|
91
|
+
function getTargetBySelector(selector) {
|
|
92
|
+
if (!selector) return null;
|
|
77
93
|
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
if (selector.charAt(0) === '@') {
|
|
95
|
+
var containerId = selector.length === 1 ? null : selector.substr(1);
|
|
96
|
+
return getTargetByContainer(containerId);
|
|
97
|
+
}
|
|
80
98
|
|
|
81
|
-
|
|
82
|
-
}
|
|
99
|
+
var next = (0, _utils.parseSelector)(selector)[0];
|
|
83
100
|
|
|
84
|
-
|
|
85
|
-
|
|
101
|
+
if (next) {
|
|
102
|
+
if ((0, _container.isContainer)(next)) {
|
|
103
|
+
return getTargetByContainer((0, _container.getContainerId)(next));
|
|
104
|
+
}
|
|
86
105
|
|
|
87
|
-
|
|
88
|
-
return getTargetByContainer(getContainerId(next));
|
|
89
|
-
}
|
|
106
|
+
var nextContainerIds = (0, _container.getContainersForNode)(next);
|
|
90
107
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
108
|
+
if ((0, _container.isNavigable)(next, (0, _last["default"])(nextContainerIds), true)) {
|
|
109
|
+
return next;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
96
112
|
|
|
97
|
-
|
|
113
|
+
return null;
|
|
98
114
|
}
|
|
99
115
|
|
|
100
|
-
function isRestrictedContainer
|
|
101
|
-
|
|
102
|
-
|
|
116
|
+
function isRestrictedContainer(containerId) {
|
|
117
|
+
var config = (0, _container.getContainerConfig)(containerId);
|
|
118
|
+
return config && (config.enterTo === 'last-focused' || config.enterTo === 'default-element');
|
|
103
119
|
}
|
|
104
120
|
|
|
105
|
-
function filterRects
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
121
|
+
function filterRects(elementRects, boundingRect) {
|
|
122
|
+
if (!boundingRect) {
|
|
123
|
+
return elementRects;
|
|
124
|
+
} // remove elements that are outside of boundingRect, if specified
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
return elementRects.filter(function (rect) {
|
|
128
|
+
if ((0, _container.isContainer)(rect.element)) {
|
|
129
|
+
// For containers, test intersection since they may be larger than the bounding rect
|
|
130
|
+
return (0, _utils.intersects)(boundingRect, rect);
|
|
131
|
+
} else {
|
|
132
|
+
// For elements, use contains with the center to include mostly visible elements
|
|
133
|
+
return (0, _utils.contains)(boundingRect, rect.center);
|
|
134
|
+
}
|
|
135
|
+
}).map(function (rect) {
|
|
136
|
+
var topUpdate = rect.top < boundingRect.top;
|
|
137
|
+
var bottomUpdate = rect.bottom > boundingRect.bottom;
|
|
138
|
+
var leftUpdate = rect.left < boundingRect.left;
|
|
139
|
+
var rightUpdate = rect.right > boundingRect.right; // if the element's rect is larger than the bounding rect, clamp it to the bounding rect and
|
|
140
|
+
// recalculate the center based on the new bounds.
|
|
141
|
+
|
|
142
|
+
if (topUpdate || bottomUpdate || leftUpdate || rightUpdate) {
|
|
143
|
+
var updated = _objectSpread(_objectSpread({}, rect), {}, {
|
|
144
|
+
center: _objectSpread({}, rect.center)
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
if (topUpdate) updated.top = boundingRect.top;
|
|
148
|
+
if (bottomUpdate) updated.bottom = boundingRect.bottom;
|
|
149
|
+
if (leftUpdate) updated.left = boundingRect.left;
|
|
150
|
+
if (rightUpdate) updated.right = boundingRect.right;
|
|
151
|
+
|
|
152
|
+
if (leftUpdate || rightUpdate) {
|
|
153
|
+
var centerX = updated.left + (updated.right - updated.left) / 2;
|
|
154
|
+
updated.center.x = updated.center.left = updated.center.right = centerX;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (topUpdate || bottomUpdate) {
|
|
158
|
+
var centerY = updated.top + (updated.bottom - updated.top) / 2;
|
|
159
|
+
updated.center.y = updated.center.top = updated.center.bottom = centerY;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return updated;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return rect;
|
|
166
|
+
});
|
|
150
167
|
}
|
|
151
168
|
|
|
152
|
-
function getContainerContainingRect
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
169
|
+
function getContainerContainingRect(elementRects, elementRect) {
|
|
170
|
+
// find candidates that are containers and *visually* contain element
|
|
171
|
+
var overlapping = elementRects.filter(function (rect) {
|
|
172
|
+
return (0, _container.isContainer)(rect.element) && (0, _utils.contains)(rect, elementRect);
|
|
173
|
+
}); // if the next element is a container AND the current element is *visually* contained within
|
|
174
|
+
// one of the candidate element, we need to ignore container `enterTo` preferences and
|
|
175
|
+
// retrieve its spottable descendants and try to navigate to them.
|
|
157
176
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (overlapping.length) {
|
|
162
|
-
return overlapping[0].element.dataset.spotlightId;
|
|
163
|
-
}
|
|
177
|
+
if (overlapping.length) {
|
|
178
|
+
return overlapping[0].element.dataset.spotlightId;
|
|
179
|
+
}
|
|
164
180
|
|
|
165
|
-
|
|
181
|
+
return false;
|
|
166
182
|
}
|
|
167
183
|
|
|
168
|
-
function getOverflowContainerRect
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (nextConfig && nextConfig.overflow) {
|
|
175
|
-
return getContainerRect(containerId);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
184
|
+
function getOverflowContainerRect(containerId) {
|
|
185
|
+
// if the target container has overflowing content, update the boundingRect to match its
|
|
186
|
+
// bounds to prevent finding elements within the container's hierarchy but not visible.
|
|
187
|
+
// This filter only applies when waterfalling to prevent filtering out elements that share
|
|
188
|
+
// a container tree with `element`
|
|
189
|
+
var nextConfig = (0, _container.getContainerConfig)(containerId);
|
|
178
190
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
let next = null;
|
|
184
|
-
|
|
185
|
-
while (elementRects.length > 0) {
|
|
186
|
-
const overlappingContainerId = getContainerContainingRect(elementRects, positionRect);
|
|
187
|
-
|
|
188
|
-
// if the pointer is within a container that is a candidate element, we need to ignore container
|
|
189
|
-
// `enterTo` preferences and retrieve its spottable descendants and try to navigate to them.
|
|
190
|
-
if (overlappingContainerId) {
|
|
191
|
-
next = getTargetInContainerByDirectionFromPosition(
|
|
192
|
-
direction,
|
|
193
|
-
overlappingContainerId,
|
|
194
|
-
positionRect,
|
|
195
|
-
elementContainerIds,
|
|
196
|
-
boundingRect
|
|
197
|
-
);
|
|
198
|
-
|
|
199
|
-
if (!next) {
|
|
200
|
-
// filter out the container and try again
|
|
201
|
-
elementRects = elementRects.filter(rect => {
|
|
202
|
-
return rect.element.dataset.spotlightId !== overlappingContainerId;
|
|
203
|
-
});
|
|
204
|
-
continue;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// found a target so break out and return
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// try to navigate from position to one of the candidates in containerId
|
|
212
|
-
next = navigate(
|
|
213
|
-
positionRect,
|
|
214
|
-
direction,
|
|
215
|
-
elementRects,
|
|
216
|
-
getContainerConfig(containerId)
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
// if we match a container, recurse into it
|
|
220
|
-
if (next && isContainer(next)) {
|
|
221
|
-
const nextContainerId = next.dataset.spotlightId;
|
|
222
|
-
|
|
223
|
-
// need to cache this reference so we can filter it out later if necessary
|
|
224
|
-
const lastNavigated = next;
|
|
225
|
-
|
|
226
|
-
next = getTargetInContainerByDirectionFromPosition(
|
|
227
|
-
direction,
|
|
228
|
-
nextContainerId,
|
|
229
|
-
positionRect,
|
|
230
|
-
elementContainerIds,
|
|
231
|
-
getOverflowContainerRect(nextContainerId) || boundingRect
|
|
232
|
-
);
|
|
233
|
-
|
|
234
|
-
if (!next) {
|
|
235
|
-
// filter out the container and try again
|
|
236
|
-
elementRects = elementRects.filter(rect => rect.element !== lastNavigated);
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
// If we've met every condition and haven't explicitly retried the search via `continue`,
|
|
242
|
-
// break out and return
|
|
243
|
-
break;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return next;
|
|
191
|
+
if (nextConfig && nextConfig.overflow) {
|
|
192
|
+
return (0, _utils.getContainerRect)(containerId);
|
|
193
|
+
}
|
|
247
194
|
}
|
|
248
195
|
|
|
196
|
+
function getTargetInContainerByDirectionFromPosition(direction, containerId, positionRect, elementContainerIds, boundingRect) {
|
|
197
|
+
var elements = (0, _container.getDeepSpottableDescendants)(containerId);
|
|
198
|
+
var elementRects = filterRects((0, _utils.getRects)(elements), boundingRect);
|
|
199
|
+
var next = null;
|
|
200
|
+
|
|
201
|
+
var _loop = function _loop() {
|
|
202
|
+
var overlappingContainerId = getContainerContainingRect(elementRects, positionRect); // if the pointer is within a container that is a candidate element, we need to ignore container
|
|
203
|
+
// `enterTo` preferences and retrieve its spottable descendants and try to navigate to them.
|
|
204
|
+
|
|
205
|
+
if (overlappingContainerId) {
|
|
206
|
+
next = getTargetInContainerByDirectionFromPosition(direction, overlappingContainerId, positionRect, elementContainerIds, boundingRect);
|
|
207
|
+
|
|
208
|
+
if (!next) {
|
|
209
|
+
// filter out the container and try again
|
|
210
|
+
elementRects = elementRects.filter(function (rect) {
|
|
211
|
+
return rect.element.dataset.spotlightId !== overlappingContainerId;
|
|
212
|
+
});
|
|
213
|
+
return "continue";
|
|
214
|
+
} // found a target so break out and return
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
return "break";
|
|
218
|
+
} // try to navigate from position to one of the candidates in containerId
|
|
249
219
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
next = getTargetInContainerByDirectionFromElement(
|
|
282
|
-
direction,
|
|
283
|
-
overlappingContainerId,
|
|
284
|
-
element,
|
|
285
|
-
elementRect,
|
|
286
|
-
elementContainerIds,
|
|
287
|
-
boundingRect
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
if (!next) {
|
|
291
|
-
// filter out the container and try again
|
|
292
|
-
elementRects = elementRects.filter(rect => {
|
|
293
|
-
return rect.element.dataset.spotlightId !== overlappingContainerId;
|
|
294
|
-
});
|
|
295
|
-
continue;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
// found a target so break out and return
|
|
299
|
-
break;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
// If one of the downstream containers is configured for partition, we use that
|
|
303
|
-
// container's bounds as the partition rect for navigation.
|
|
304
|
-
const partitionContainer = elementContainerIds
|
|
305
|
-
.slice(elementContainerIds.indexOf(containerId) + 1)
|
|
306
|
-
.find(id => {
|
|
307
|
-
const cfg = getContainerConfig(id);
|
|
308
|
-
return cfg && cfg.partition;
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
let partitionRect = elementRect;
|
|
312
|
-
if (partitionContainer) {
|
|
313
|
-
partitionRect = getContainerRect(partitionContainer);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
// try to navigate from element to one of the candidates in containerId
|
|
317
|
-
next = navigate(
|
|
318
|
-
elementRect,
|
|
319
|
-
direction,
|
|
320
|
-
elementRects,
|
|
321
|
-
getContainerConfig(containerId),
|
|
322
|
-
partitionRect
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
// if we match a container,
|
|
326
|
-
if (next && isContainer(next)) {
|
|
327
|
-
const nextContainerId = next.dataset.spotlightId;
|
|
328
|
-
|
|
329
|
-
// need to cache this reference so we can filter it out later if necessary
|
|
330
|
-
const lastNavigated = next;
|
|
331
|
-
|
|
332
|
-
// and it is restricted, return its target
|
|
333
|
-
if (isRestrictedContainer(nextContainerId)) {
|
|
334
|
-
next = getTargetByContainer(nextContainerId);
|
|
335
|
-
} else {
|
|
336
|
-
// otherwise, recurse into it
|
|
337
|
-
next = getTargetInContainerByDirectionFromElement(
|
|
338
|
-
direction,
|
|
339
|
-
nextContainerId,
|
|
340
|
-
element,
|
|
341
|
-
elementRect,
|
|
342
|
-
elementContainerIds,
|
|
343
|
-
getOverflowContainerRect(nextContainerId) || boundingRect
|
|
344
|
-
);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (!next) {
|
|
348
|
-
elementRects = elementRects.filter(rect => rect.element !== lastNavigated);
|
|
349
|
-
continue;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// If we've met every condition and haven't explicitly retried the search via `continue`,
|
|
354
|
-
// break out and return
|
|
355
|
-
break;
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
return next;
|
|
220
|
+
|
|
221
|
+
next = (0, _navigate["default"])(positionRect, direction, elementRects, (0, _container.getContainerConfig)(containerId)); // if we match a container, recurse into it
|
|
222
|
+
|
|
223
|
+
if (next && (0, _container.isContainer)(next)) {
|
|
224
|
+
var nextContainerId = next.dataset.spotlightId; // need to cache this reference so we can filter it out later if necessary
|
|
225
|
+
|
|
226
|
+
var lastNavigated = next;
|
|
227
|
+
next = getTargetInContainerByDirectionFromPosition(direction, nextContainerId, positionRect, elementContainerIds, getOverflowContainerRect(nextContainerId) || boundingRect);
|
|
228
|
+
|
|
229
|
+
if (!next) {
|
|
230
|
+
// filter out the container and try again
|
|
231
|
+
elementRects = elementRects.filter(function (rect) {
|
|
232
|
+
return rect.element !== lastNavigated;
|
|
233
|
+
});
|
|
234
|
+
return "continue";
|
|
235
|
+
}
|
|
236
|
+
} // If we've met every condition and haven't explicitly retried the search via `continue`,
|
|
237
|
+
// break out and return
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
return "break";
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
while (elementRects.length > 0) {
|
|
244
|
+
var _ret = _loop();
|
|
245
|
+
|
|
246
|
+
if (_ret === "continue") continue;
|
|
247
|
+
if (_ret === "break") break;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return next;
|
|
359
251
|
}
|
|
360
252
|
|
|
361
|
-
function
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
253
|
+
function getTargetInContainerByDirectionFromElement(direction, containerId, element, elementRect, elementContainerIds, boundingRect) {
|
|
254
|
+
var elements = (0, _container.getDeepSpottableDescendants)(containerId); // shortcut for previous target from element if it were saved
|
|
255
|
+
|
|
256
|
+
var previous = (0, _container.getContainerPreviousTarget)(containerId, direction, element);
|
|
257
|
+
|
|
258
|
+
if (previous && elements.indexOf(previous) !== -1) {
|
|
259
|
+
return previous;
|
|
260
|
+
} // `spotlightOverflow` is a private, and likely temporary, API to allow a component within an
|
|
261
|
+
// spotlight container with `overflow: true` to be treated as if it were outside of the
|
|
262
|
+
// container. The result is that the candidates, `elements` are filtered by the bounds of the
|
|
263
|
+
// overflow container effectively hiding those that have overflowed and are visually hidden.
|
|
264
|
+
//
|
|
265
|
+
// Currently only used by moonstone/Scroller.Scrollbar as a means to allow 5-way navigation to
|
|
266
|
+
// escape the Scrollable from paging controls rather than focusing contents that are out of view
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
if (element.dataset.spotlightOverflow === 'ignore') {
|
|
270
|
+
boundingRect = getOverflowContainerRect(containerId) || boundingRect;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
var elementRects = filterRects((0, _utils.getRects)(elements), boundingRect);
|
|
274
|
+
var next = null;
|
|
275
|
+
|
|
276
|
+
var _loop2 = function _loop2() {
|
|
277
|
+
var overlappingContainerId = getContainerContainingRect(elementRects, elementRect); // if the next element is a container AND the current element is *visually* contained within
|
|
278
|
+
// one of the candidate elements, we need to ignore container `enterTo` preferences and
|
|
279
|
+
// retrieve its spottable descendants and try to navigate to them.
|
|
280
|
+
|
|
281
|
+
if (overlappingContainerId) {
|
|
282
|
+
next = getTargetInContainerByDirectionFromElement(direction, overlappingContainerId, element, elementRect, elementContainerIds, boundingRect);
|
|
283
|
+
|
|
284
|
+
if (!next) {
|
|
285
|
+
// filter out the container and try again
|
|
286
|
+
elementRects = elementRects.filter(function (rect) {
|
|
287
|
+
return rect.element.dataset.spotlightId !== overlappingContainerId;
|
|
288
|
+
});
|
|
289
|
+
return "continue";
|
|
290
|
+
} // found a target so break out and return
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
return "break";
|
|
294
|
+
} // If one of the downstream containers is configured for partition, we use that
|
|
295
|
+
// container's bounds as the partition rect for navigation.
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
var partitionContainer = elementContainerIds.slice(elementContainerIds.indexOf(containerId) + 1).find(function (id) {
|
|
299
|
+
var cfg = (0, _container.getContainerConfig)(id);
|
|
300
|
+
return cfg && cfg.partition;
|
|
301
|
+
});
|
|
302
|
+
var partitionRect = elementRect;
|
|
303
|
+
|
|
304
|
+
if (partitionContainer) {
|
|
305
|
+
partitionRect = (0, _utils.getContainerRect)(partitionContainer);
|
|
306
|
+
} // try to navigate from element to one of the candidates in containerId
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
next = (0, _navigate["default"])(elementRect, direction, elementRects, (0, _container.getContainerConfig)(containerId), partitionRect); // if we match a container,
|
|
310
|
+
|
|
311
|
+
if (next && (0, _container.isContainer)(next)) {
|
|
312
|
+
var nextContainerId = next.dataset.spotlightId; // need to cache this reference so we can filter it out later if necessary
|
|
313
|
+
|
|
314
|
+
var lastNavigated = next; // and it is restricted, return its target
|
|
315
|
+
|
|
316
|
+
if (isRestrictedContainer(nextContainerId)) {
|
|
317
|
+
next = getTargetByContainer(nextContainerId);
|
|
318
|
+
} else {
|
|
319
|
+
// otherwise, recurse into it
|
|
320
|
+
next = getTargetInContainerByDirectionFromElement(direction, nextContainerId, element, elementRect, elementContainerIds, getOverflowContainerRect(nextContainerId) || boundingRect);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (!next) {
|
|
324
|
+
elementRects = elementRects.filter(function (rect) {
|
|
325
|
+
return rect.element !== lastNavigated;
|
|
326
|
+
});
|
|
327
|
+
return "continue";
|
|
328
|
+
}
|
|
329
|
+
} // If we've met every condition and haven't explicitly retried the search via `continue`,
|
|
330
|
+
// break out and return
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
return "break";
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
while (elementRects.length > 0) {
|
|
337
|
+
var _ret2 = _loop2();
|
|
338
|
+
|
|
339
|
+
if (_ret2 === "continue") continue;
|
|
340
|
+
if (_ret2 === "break") break;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return next;
|
|
396
344
|
}
|
|
397
345
|
|
|
398
|
-
function
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
346
|
+
function getTargetByDirectionFromElement(direction, element) {
|
|
347
|
+
var extSelector = element.getAttribute('data-spot-' + direction);
|
|
348
|
+
|
|
349
|
+
if (typeof extSelector === 'string') {
|
|
350
|
+
return getTargetBySelector(extSelector);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
var elementRect = (0, _utils.getRect)(element);
|
|
354
|
+
var next = (0, _container.getNavigableContainersForNode)(element).reduceRight(function (result, containerId, index, elementContainerIds) {
|
|
355
|
+
result = result || getTargetInContainerByDirectionFromElement(direction, containerId, element, elementRect, elementContainerIds);
|
|
356
|
+
|
|
357
|
+
if (!result) {
|
|
358
|
+
result = getLeaveForTarget(containerId, direction); // To support a `leaveFor` configuration with navigation disallowed in the current
|
|
359
|
+
// `direction`, we return the current element to prevent further searches for a
|
|
360
|
+
// target in this reduction.
|
|
361
|
+
|
|
362
|
+
if (result === false) {
|
|
363
|
+
result = element;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return result;
|
|
368
|
+
}, null); // if the reduce above returns the original element, it means it hit a `leaveFor` config that
|
|
369
|
+
// prevents navigation so we enforce that here by returning null.
|
|
370
|
+
|
|
371
|
+
return next !== element ? next : null;
|
|
411
372
|
}
|
|
412
373
|
|
|
374
|
+
function getTargetByDirectionFromPosition(direction, position, containerId) {
|
|
375
|
+
var pointerRect = (0, _utils.getPointRect)(position);
|
|
376
|
+
return (0, _container.getNavigableContainersForNode)((0, _container.getContainerNode)(containerId)).reduceRight(function (result, id, index, elementContainerIds) {
|
|
377
|
+
return result || getTargetInContainerByDirectionFromPosition(direction, id, pointerRect, elementContainerIds);
|
|
378
|
+
}, null);
|
|
379
|
+
}
|
|
413
380
|
/**
|
|
414
381
|
* Returns the target identified by the selector configured for the container identified by
|
|
415
382
|
* `containerId` for the given `direction`. If the selector is an empty string, the method returns
|
|
@@ -421,113 +388,120 @@ function getTargetByDirectionFromPosition (direction, position, containerId) {
|
|
|
421
388
|
* @returns {Node|Boolean} Target, if found, or `false` if navigation is disallowed
|
|
422
389
|
* @private
|
|
423
390
|
*/
|
|
424
|
-
function getLeaveForTarget (containerId, direction) {
|
|
425
|
-
const config = getContainerConfig(containerId);
|
|
426
|
-
|
|
427
|
-
if (config) {
|
|
428
|
-
const target = config.restrict !== 'self-only' && config.leaveFor && config.leaveFor[direction];
|
|
429
|
-
if (typeof target === 'string') {
|
|
430
|
-
if (target === '') {
|
|
431
|
-
return false;
|
|
432
|
-
}
|
|
433
|
-
return getTargetBySelector(target);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
const nextContainerIds = getContainersForNode(target);
|
|
437
|
-
if (isNavigable(target, last(nextContainerIds))) {
|
|
438
|
-
return target;
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
return null;
|
|
443
|
-
}
|
|
444
391
|
|
|
445
|
-
function getNavigableTarget (target) {
|
|
446
|
-
if (target === document) return null;
|
|
447
392
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
393
|
+
function getLeaveForTarget(containerId, direction) {
|
|
394
|
+
var config = (0, _container.getContainerConfig)(containerId);
|
|
395
|
+
|
|
396
|
+
if (config) {
|
|
397
|
+
var target = config.restrict !== 'self-only' && config.leaveFor && config.leaveFor[direction];
|
|
398
|
+
|
|
399
|
+
if (typeof target === 'string') {
|
|
400
|
+
if (target === '') {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
return getTargetBySelector(target);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
var nextContainerIds = (0, _container.getContainersForNode)(target);
|
|
408
|
+
|
|
409
|
+
if ((0, _container.isNavigable)(target, (0, _last["default"])(nextContainerIds))) {
|
|
410
|
+
return target;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return null;
|
|
454
415
|
}
|
|
455
416
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
distance += y - bottom;
|
|
460
|
-
} else if (y < top) {
|
|
461
|
-
distance += top - y;
|
|
462
|
-
}
|
|
463
|
-
} else if (x > right) {
|
|
464
|
-
distance += x - right;
|
|
465
|
-
} else if (x < left) {
|
|
466
|
-
distance += left - x;
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
return distance;
|
|
470
|
-
};
|
|
417
|
+
function getNavigableTarget(target) {
|
|
418
|
+
if (target === document) return null;
|
|
419
|
+
var parent;
|
|
471
420
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
if (direction === 'left') {
|
|
477
|
-
distance = x - elementRect.right;
|
|
478
|
-
} else if (direction === 'right') {
|
|
479
|
-
distance = elementRect.left - x;
|
|
480
|
-
} else if (direction === 'up') {
|
|
481
|
-
distance = y - elementRect.bottom;
|
|
482
|
-
} else if (direction === 'down') {
|
|
483
|
-
distance = elementRect.top - y;
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
return getOffsetDistanceToTargetFromPosition(clamp(0, Math.abs(distance), distance), direction, position, elementRect);
|
|
487
|
-
};
|
|
421
|
+
while (target && ((0, _container.isContainer)(target) || !isFocusable(target))) {
|
|
422
|
+
parent = target.parentNode;
|
|
423
|
+
target = parent === document ? null : parent; // calling isNavigable on document is problematic
|
|
424
|
+
}
|
|
488
425
|
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
const target = getTargetByDirectionFromPosition(direction, position, containerId);
|
|
426
|
+
return target;
|
|
427
|
+
}
|
|
492
428
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
429
|
+
var getOffsetDistanceToTargetFromPosition = function getOffsetDistanceToTargetFromPosition(distance, direction, _ref, _ref2) {
|
|
430
|
+
var x = _ref.x,
|
|
431
|
+
y = _ref.y;
|
|
432
|
+
var left = _ref2.left,
|
|
433
|
+
right = _ref2.right,
|
|
434
|
+
top = _ref2.top,
|
|
435
|
+
bottom = _ref2.bottom;
|
|
436
|
+
|
|
437
|
+
if (direction === 'left' || direction === 'right') {
|
|
438
|
+
if (y > bottom) {
|
|
439
|
+
distance += y - bottom;
|
|
440
|
+
} else if (y < top) {
|
|
441
|
+
distance += top - y;
|
|
442
|
+
}
|
|
443
|
+
} else if (x > right) {
|
|
444
|
+
distance += x - right;
|
|
445
|
+
} else if (x < left) {
|
|
446
|
+
distance += left - x;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return distance;
|
|
450
|
+
};
|
|
499
451
|
|
|
500
|
-
|
|
501
|
-
|
|
452
|
+
var getDistanceToTargetFromPosition = function getDistanceToTargetFromPosition(direction, position, elementRect) {
|
|
453
|
+
var x = position.x,
|
|
454
|
+
y = position.y;
|
|
455
|
+
var distance;
|
|
456
|
+
|
|
457
|
+
if (direction === 'left') {
|
|
458
|
+
distance = x - elementRect.right;
|
|
459
|
+
} else if (direction === 'right') {
|
|
460
|
+
distance = elementRect.left - x;
|
|
461
|
+
} else if (direction === 'up') {
|
|
462
|
+
distance = y - elementRect.bottom;
|
|
463
|
+
} else if (direction === 'down') {
|
|
464
|
+
distance = elementRect.top - y;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
return getOffsetDistanceToTargetFromPosition((0, _clamp["default"])(0, Math.abs(distance), distance), direction, position, elementRect);
|
|
502
468
|
};
|
|
503
469
|
|
|
504
|
-
|
|
505
|
-
|
|
470
|
+
var getNearestTargetsInContainerFromPosition = function getNearestTargetsInContainerFromPosition(position, containerId) {
|
|
471
|
+
return ['up', 'left', 'right', 'down'].reduce(function (result, direction) {
|
|
472
|
+
var target = getTargetByDirectionFromPosition(direction, position, containerId);
|
|
506
473
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
474
|
+
if (target) {
|
|
475
|
+
result.push({
|
|
476
|
+
direction: direction,
|
|
477
|
+
target: target
|
|
478
|
+
});
|
|
479
|
+
}
|
|
510
480
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
});
|
|
481
|
+
return result;
|
|
482
|
+
}, []);
|
|
483
|
+
};
|
|
515
484
|
|
|
516
|
-
|
|
517
|
-
|
|
485
|
+
var getNearestTargetInContainerFromPosition = function getNearestTargetInContainerFromPosition(position, containerId) {
|
|
486
|
+
var targets = getNearestTargetsInContainerFromPosition(position, containerId);
|
|
487
|
+
|
|
488
|
+
if (!targets.length) {
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
targets.forEach(function (item) {
|
|
493
|
+
var direction = item.direction,
|
|
494
|
+
target = item.target;
|
|
495
|
+
item.distance = getDistanceToTargetFromPosition(direction, position, (0, _utils.getRect)(target));
|
|
496
|
+
});
|
|
497
|
+
targets.sort(function (a, b) {
|
|
498
|
+
return a.distance - b.distance;
|
|
499
|
+
});
|
|
500
|
+
return targets[0].target;
|
|
518
501
|
};
|
|
519
502
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
getNearestTargetInContainerFromPosition(position, containerId)
|
|
523
|
-
);
|
|
524
|
-
|
|
525
|
-
export {
|
|
526
|
-
getNavigableTarget,
|
|
527
|
-
getNearestTargetFromPosition,
|
|
528
|
-
getTargetByContainer,
|
|
529
|
-
getTargetByDirectionFromElement,
|
|
530
|
-
getTargetByDirectionFromPosition,
|
|
531
|
-
getTargetBySelector,
|
|
532
|
-
isFocusable
|
|
503
|
+
var getNearestTargetFromPosition = function getNearestTargetFromPosition(position, containerId) {
|
|
504
|
+
return getNavigableTarget(document.elementFromPoint(position.x, position.y)) || getNearestTargetInContainerFromPosition(position, containerId);
|
|
533
505
|
};
|
|
506
|
+
|
|
507
|
+
exports.getNearestTargetFromPosition = getNearestTargetFromPosition;
|