INNER CODE UNIT · TypeScript
prev
hyscaler/HyCanvas · packages/a11y/src/index.ts:119
const prev = center(ordered[i - 1]);
const next = center(ordered[i]);
// A clear backward jump: the next announced element sits entirely ABOVE
// the previous one's row, or on the same row but behind it in the
// document's reading direction. Column layouts survive: reading a
// second column top-to-bottom produces only ONE upward jump.
const above = next.cy < prev.top;
const sameRow = !above && Math.abs(next.cy - prev.cy) < 8;
const behind = sameRow && (rtl ? next.cx > prev.cx : next.cx < prev.cx);
if (above || behind) backward++;
}
if (backward >= 2 && backward / (ordered.length - 1) > 0.34) {
issues.push({
nodeId: page.id,
nodeName: page.name,
pageIndex,
kind: "reading-order",
severity: "warning",