File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -435,7 +435,7 @@ The {{Element/seqNavSearch()}} method must follow these steps:
435435
436436</div>
437437
438- <div class=example>
438+ <div class=example id=focus-only >
439439 The following code changes the behavior of spatial navigation
440440 from scrolling when there is no focusable element visible,
441441 to jumping to focusable elements even when they are not visible.
@@ -457,6 +457,32 @@ The {{Element/seqNavSearch()}} method must follow these steps:
457457 </code></pre>
458458</div>
459459
460+ <div class=example id=delegation>
461+ The following code changes the behavior of spatial navigation
462+ so that when a scroll container would get focused,
463+ if it has at least one visible focusable descendant,
464+ the focus is automatically transfered to it.
465+
466+ <pre><code highlight=javascript>
467+ document.addEventListener("navbeforefocus", function(e) {
468+ e.preventDefault();
469+
470+ var e1 = e.relatedTarget;
471+ while (e1.isSameNode(e1.getSpatnavContainer())) {
472+ var areas = e1.focusableAreas();
473+
474+ if (areas.length == 0)) { break; }
475+
476+ e1 = e1.spatNavSearch({
477+ dir: e.dir,
478+ candidates: areas
479+ });
480+ }
481+ e1.focus();
482+ });
483+ </code></pre>
484+ </div>
485+
460486
461487<h2 id="events-navigationevent">
462488Navigation Events</h2>
You can’t perform that action at this time.
0 commit comments