Skip to content

Commit 054ba11

Browse files
author
Jihye Hong
authored
Merge pull request #3729 from jihyerish/drop-navbeforescroll
[css-nav-1] Drop navbeforescroll event
2 parents acaa7d3 + 9753ac3 commit 054ba11

File tree

1 file changed

+6
-148
lines changed

1 file changed

+6
-148
lines changed

css-nav-1/Overview.bs

+6-148
Original file line numberDiff line numberDiff line change
@@ -540,29 +540,6 @@ this only searches through the visible focusable areas of the nearest
540540
and the result will be <code>null</code>.</strong>
541541
</div>
542542

543-
544-
<div class=example id=focus-only>
545-
The following code changes the behavior of spatial navigation
546-
from scrolling when there is no focusable element visible,
547-
to jumping to focusable elements even when they are not visible.
548-
549-
<pre><code highlight=javascript>
550-
document.addEventListener("navbeforescroll", function(e) {
551-
var container = e.relatedTarget;
552-
var areas = container.focusableAreas({ mode: "all" });
553-
554-
if (areas.length === 0) { return; }
555-
556-
e.preventDefault();
557-
var t = e.target.spatialNavigationSearch({
558-
dir: e.dir,
559-
candidates: areas
560-
});
561-
t.focus();
562-
});
563-
</code></pre>
564-
</div>
565-
566543
<div class=example id=delegation>
567544
The following code changes the behavior of spatial navigation
568545
so that when a scroll container would get focused,
@@ -744,113 +721,6 @@ The <a event>navbeforefocus</a> event occurs before spatial navigation changes t
744721
</table>
745722
</div>
746723

747-
<h4 id="event-type-navbeforescroll" class="non-normative">
748-
<dfn event for=NavigationEvent>navbeforescroll</dfn></h4>
749-
750-
The <a event>navbeforescroll</a> event occurs before spatial navigation triggers scrolling.
751-
<table class="def">
752-
<tbody>
753-
<tr>
754-
<th>Type
755-
<td><strong><code>navbeforescroll</code></strong>
756-
<tr>
757-
<th>Interface
758-
<td>{{NavigationEvent}}
759-
<tr>
760-
<th>Bubbles
761-
<td>Yes
762-
<tr>
763-
<th>Cancelable
764-
<td>Yes
765-
<tr>
766-
<th>Attributes of the event
767-
<td><dl>
768-
<dt>{{NavigationEvent}}.{{NavigationEvent/relatedTarget}}
769-
<dd>The element that will be scrolled if the event is not canceled
770-
771-
<dt>{{NavigationEvent}}.{{NavigationEvent/dir}}
772-
<dd>The direction of the navigation as requested by the user
773-
</dl>
774-
</tbody>
775-
</table>
776-
777-
<div class='example'>
778-
This example shows the [[UI-EVENTS#event-order]] when pressing the <code class=key>ArrowDown</code>
779-
key in the situation like the following figure.
780-
For the sake of keeping the description simple,
781-
this example assumes a UA where spatial navigation is triggered using arrow keys.
782-
783-
<figure>
784-
<img alt="An image about navbeforescroll" src="images/navbeforescroll-example-1.png" style="width: 200px;"/>
785-
<figcaption>"Box 2" gains the focus and there isn't any candidate in a downward direction
786-
in the <a>scrollport</a>.</figcaption>
787-
</figure>
788-
789-
<table class="complex data">
790-
<thead>
791-
<tr>
792-
<th>
793-
<th>Event type
794-
<th>Event target
795-
<th><code>relatedTarget</code>
796-
<th>Notes
797-
</thead>
798-
<tbody>
799-
<tr>
800-
<td>1
801-
<td>keydown
802-
<td><code>#box2</code>
803-
<td>N/A
804-
<td>MUST be a key which can activate spatial navigation,
805-
such as the arrow keys,
806-
otherwise spatial navigation is not triggered.
807-
<tr>
808-
<td>2
809-
<td>navbeforescroll
810-
<td><code>#box2</code>
811-
<td><code>#scrollContainer</code>
812-
<td>Sent if <code>#scrollContainer</code> doesn't contain any candidate in the <a>scrollport</a>,
813-
otherwise this would not be generated.
814-
</tbody>
815-
</table>
816-
817-
After <a event>navbeforescroll</a> is fired, pressing the <code class=key>ArrowDown</code> key triggers scrolling
818-
down the scrollbar like in the figure below:
819-
820-
<figure>
821-
<img alt="An image of the result about navnotarget" src="images/navbeforescroll-example-2.png" style="width: 200px;"/>
822-
<figcaption>The result of moving focus when there isn't any candidate in the <a>scrollport</a>.</figcaption>
823-
</figure>
824-
825-
This example uses the markup as follows:
826-
<pre class="lang-css">
827-
#scrollContainer {
828-
width: 700px;
829-
height: 700px;
830-
overflow-x: hidden;
831-
overflow-y: auto;
832-
}
833-
834-
.item {
835-
width: 150px;
836-
height: 110px;
837-
background-color: blue;
838-
}
839-
840-
.item:focus {
841-
background-color: red;
842-
}
843-
</pre>
844-
845-
<pre class="lang-html">
846-
&lt;div id="scrollContainer">
847-
&lt;div id="box1" class="item" tabindex="0">Box 1&lt;/div>
848-
&lt;div id="box2" class="item" tabindex="0">Box 2&lt;/div>
849-
&lt;div id="box3" class="item" tabindex="0">Box 3&lt;/div>
850-
&lt;/div>
851-
</pre>
852-
</div>
853-
854724
<h4 id="event-type-navnotarget" class="non-normative">
855725
<dfn event for=NavigationEvent>navnotarget</dfn></h4>
856726

@@ -1086,7 +956,7 @@ To run the <dfn>spatial navigation steps</dfn> in <var>direction</var>, do the f
1086956
1. Let <var>searchOrigin</var> be the <a>DOM anchor</a> of the <a>currently focused area of a top-level browsing context</a>.
1087957
2. If the <a>spatial navigation starting point</a> is not <code>null</code>
1088958
and it is inside <var>searchOrigin</var>
1089-
then set <var>searchOrigin</var> to the <a>spatial navigation starting point</a>
959+
then set <var>searchOrigin</var> to the <a>spatial navigation starting point</a>.
1090960
3.
1091961
* If <var>searchOrigin</var> is an <a>node</a>,
1092962
let <var>eventTarget</var> be <var>searchOrigin</var>
@@ -1108,27 +978,15 @@ To run the <dfn>spatial navigation steps</dfn> in <var>direction</var>, do the f
1108978
and with it's <code>bubbles</code> and <code>cancelable</code> attributes set to <code>true</code>,
1109979
and return if the result is <code>false</code></span>
1110980
3. Run the <a>focusing steps</a> for <var>bestCandidate</var> and return
1111-
* Else if <var>eventTarget</var> <a>can be manually scrolled</a>:
1112-
1. If <a>navigation-override</a> <a>is enabled</a> in the [=node document=] of <var>eventTarget</var> for the <a spec=html for="/">origin</a> of the [=active document=] of the [=top-level browsing context=], then
1113-
<span class=api><a>fire an event</a> named <a event>navbeforescroll</a> at <var>eventTarget</var> using {{NavigationEvent}}
1114-
with its {{NavigationEvent/dir}} set to <var>direction</var>
1115-
and {{NavigationEvent/relatedTarget}} set to <var>eventTarget</var>
1116-
and with it's <code>bubbles</code> and <code>cancelable</code> attributes set to <code>true</code>,
1117-
and return if the result is <code>false</code></span>
1118-
2. <a>Directionally scroll the element</a> <var>eventTarget</var> in <var>direction</var> and return.
1119-
* Else, fallback to the next step
981+
* Else if <var>eventTarget</var> <a>can be manually scrolled</a>, <a>directionally scroll the element</a>
982+
<var>eventTarget</var> in <var>direction</var> and return.
983+
* Else, fallback to the next step.
1120984
6. Let <var>container</var> be the nearest ancestor of <var>eventTarget</var> that is a <a>spatial navigation container</a>.
1121985
7. <i>Loop</i>: Let <var>candidates</var> be the result of <a>finding focusable areas</a>
1122986
within <var>container</var>, excluding <var>searchOrigin</var>
1123987
8. If <var>candidates</var> is empty:
1124-
* If <var>container</var> is a <a>scroll container</a> that <a>can be manually scrolled</a>:
1125-
1. If <a>navigation-override</a> <a>is enabled</a> in the [=node document=] of <var>eventTarget</var> for the <a spec=html for="/">origin</a> of the [=active document=] of the [=top-level browsing context=], then
1126-
<span class=api><a>fire an event</a> named <a event>navbeforescroll</a> at <var>eventTarget</var> using {{NavigationEvent}}
1127-
with its {{NavigationEvent/dir}} set to <var>direction</var>
1128-
and {{NavigationEvent/relatedTarget}} set to <var>container</var>
1129-
and with it's <code>bubbles</code> and <code>cancelable</code> attributes set to <code>true</code>,
1130-
and return if the result is <code>false</code></span>
1131-
2. <a>Directionally scroll the element</a> <var>container</var> in <var>direction</var> and return.
988+
* If <var>container</var> is a <a>scroll container</a> that <a>can be manually scrolled</a>, <a>directionally scroll the element</a>
989+
<var>container</var> in <var>direction</var> and return.
1132990
* Else,
1133991
1. If <a>navigation-override</a> <a>is enabled</a> in the [=node document=] of <var>eventTarget</var> for the <a spec=html for="/">origin</a> of the [=active document=] of the [=top-level browsing context=], then
1134992
<span class=api><a>fire an event</a> named <a event>navnotarget</a> at <var>eventTarget</var> using {{NavigationEvent}}

0 commit comments

Comments
 (0)