Skip to content

Layout audits

Jqy is a layout engine for nested boxes. A parent box puts its children in a grid or on a ring. After each layout, an audit checks each child against its parent. The child must be square, and it must fit. It must stay inside the inner edge of the parent, and on the ring of a radial parent.

Each check is one Vex formula over a tree space. The move parent() reads the parent, and parent().children(...) reads each child of the parent. Vex evaluates each formula at each box. A root has no parent, so a check that reads the parent gives #REF! at the root, not a false finding.

The layout audit of Jqy3 findings

The checks at auth:

fails
passes
passes
passes
const parent = root.start(0).parent();
const inner = parent.from("size")._.subtract(2 * pad);
const innerLo = parent.from("position")._.add(pad);
root.from("position")._.subtract(innerLo)._.anyLessThan(-0.5)
  ._.or(innerLo._.add(inner)
    ._.subtract(root.from("position")._.add("size"))
    ._.anyLessThan(-0.5))
The steps of "Outside the parent" at auth
  1. position @auth → (192, 117)
  2. position @auth → (162, 95)
  3. 16 @auth → 16
  4. add @auth → (178, 111)
  5. subtract @auth → (14, 6)
  6. -0.5 @auth → -0.5
  7. anyLessThan @auth → false
  8. position @auth → (162, 95)
  9. 16 @auth → 16
  10. add @auth → (178, 111)
  11. size @auth → (52, 52)
  12. 32 @auth → 32
  13. subtract @auth → (20, 20)
  14. add @auth → (198, 131)
  15. position @auth → (192, 117)
  16. size @auth → (8, 8)
  17. add @auth → (200, 125)
  18. subtract @auth → (-2, 6)
  19. -0.5 @auth → -0.5
  20. anyLessThan @auth → true
  21. or @auth → true

Drag a box, or select it and use the arrow keys. A box moves with the boxes in it. Select a check in the table to see its formula and its steps.

The boxes are the output of Jqy for the spacing 16. The three children of api are on their ring, but each one ends 2 px after the inner edge of api. The steps of “Off the ring” show the cause. The ring that fits has the radius 4, but the smallest ring of the tuning has the radius 8. Select “Place on the rings”: the children stay outside, because the cause is the tuning, not the placement.

The package @vex/pilots has these formulas. Its tests compare them with a reference in plain TypeScript on random layouts. The two give the same findings, the same places on the rings and the same overlapping pairs.

This audit also found a defect in Vex. A move before an axis had no effect, so parent().children(...) gave the children of the origin. After the fix, the moves before an axis are its address (rule AXIS.ADDRESS, regression V-043).