* Move the focus to the best candidate or do nothing. * @function focusingController * @param bestCandidate {Node} - The best candidate of the spatial navigation * @param dir {SpatialNavigationDirection}- The directional information for the spatial navigation (e.g. LRUD) * @returns {bool
(bestCandidate, dir)
| 240 | * @returns {boolean} |
| 241 | */ |
| 242 | function focusingController(bestCandidate, dir) { |
| 243 | // 10 & 11 |
| 244 | // When bestCandidate is found |
| 245 | if (bestCandidate) { |
| 246 | // When bestCandidate is a focusable element and not a container : move focus |
| 247 | /* |
| 248 | * [event] navbeforefocus : Fired before spatial or sequential navigation changes the focus. |
| 249 | */ |
| 250 | if (!createSpatNavEvents('beforefocus', bestCandidate, null, dir)) |
| 251 | return true; |
| 252 | |
| 253 | const container = bestCandidate.getSpatialNavigationContainer(); |
| 254 | |
| 255 | if ((container !== window) && (getCSSSpatNavAction(container) === 'focus')) { |
| 256 | bestCandidate.focus(); |
| 257 | } else { |
| 258 | bestCandidate.focus({preventScroll: true}); |
| 259 | } |
| 260 | |
| 261 | startingPoint = null; |
| 262 | return true; |
| 263 | } |
| 264 | |
| 265 | // When bestCandidate is not found within the scrollport of a container: Nothing |
| 266 | return false; |
| 267 | } |
| 268 | |
| 269 | /** |
| 270 | * Directionally scroll the scrollable spatial navigation container if it can be manually scrolled more. |
no test coverage detected