stitch2 0.20.0 → 0.20.1
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/dist/audit.js +11 -7
- package/package.json +1 -1
package/dist/audit.js
CHANGED
|
@@ -218,6 +218,14 @@ export async function audit(opts) {
|
|
|
218
218
|
window.scrollTo(0, 0);
|
|
219
219
|
// 4. Tap targets: WCAG 2.2 asks for at least 24px; smaller than the config's comfortableTarget is a warning.
|
|
220
220
|
const interactive = all.filter((el) => el.matches('button, a[href], input:not([type=hidden]), select, textarea, [role=button], [role=tab], [role=switch], [role=checkbox]'));
|
|
221
|
+
// Fixed and sticky layers float over the scrolling page (a running-workout panel over cards): content slides
|
|
222
|
+
// under them while scrolling, so they never crowd in-flow targets. Tap spacing (6d) already compares layers.
|
|
223
|
+
const layerOf = (el) => {
|
|
224
|
+
for (let e = el; e; e = e.parentElement)
|
|
225
|
+
if (['fixed', 'sticky'].includes(getComputedStyle(e).position))
|
|
226
|
+
return e;
|
|
227
|
+
return null;
|
|
228
|
+
};
|
|
221
229
|
for (const el of interactive) {
|
|
222
230
|
if (interactive.some((o) => o !== el && o.contains(el)))
|
|
223
231
|
continue;
|
|
@@ -229,7 +237,7 @@ export async function audit(opts) {
|
|
|
229
237
|
const cx = r.left + r.width / 2;
|
|
230
238
|
const cy = r.top + r.height / 2;
|
|
231
239
|
const crowded = interactive.some((o) => {
|
|
232
|
-
if (o === el || o.contains(el) || el.contains(o))
|
|
240
|
+
if (o === el || o.contains(el) || el.contains(o) || layerOf(o) !== layerOf(el))
|
|
233
241
|
return false;
|
|
234
242
|
const q = o.getBoundingClientRect();
|
|
235
243
|
const dx = Math.max(q.left - cx, 0, cx - q.right);
|
|
@@ -250,12 +258,8 @@ export async function audit(opts) {
|
|
|
250
258
|
// 4b. Controls never overlap one another (a button squeezed over its neighbour). Controls inside one another
|
|
251
259
|
// and invisible overlays (a native picker laid over a row) are fine; fixed and sticky layers (a docked timer,
|
|
252
260
|
// a sticky Save bar floating over a list) are compared apart from the scrolling page.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if (['fixed', 'sticky'].includes(getComputedStyle(e).position))
|
|
256
|
-
return e;
|
|
257
|
-
return null;
|
|
258
|
-
};
|
|
261
|
+
// layerOf is defined with the tap targets above; fixed and sticky layers are compared apart here too.
|
|
262
|
+
const layer = layerOf;
|
|
259
263
|
// The part of a control its scrolling or clipping ancestors show: a link scrolled out of a nav strip is not drawn
|
|
260
264
|
// where its box would be.
|
|
261
265
|
const visibleBox = (el) => {
|
package/package.json
CHANGED