Page structure drawn in depth
Six ideas from the element catalogue, built. Each canvas draws structural elements
(<section>, <nav>, <hr>, <header>, <details>, <aside>)
in a position the page layout doesn't have: on the faces of a cube, along a curve, at different depths, folded, pulled out towards the reader, and hanging from a string.
The elements stay in the document, and the buttons, links and checkboxes inside them are pressed where they are drawn. Drag the cube and the ribbon sideways, and scroll inside the two framed pages.
Sections on a cube
Four <section> elements, one on each side face. Drag a face sideways, press a link in the <nav> under the cube, or press Tab through the controls: focus that moves into a hidden section turns it to the front.
While the cube rests, the front face is one flat draw. While it turns, the two visible faces are drawn in 26 vertical strips each, and the face that is most towards the reader takes input at its flat place.
Show the code
- A
<nav>and fourdrawablesections. - Draw the visible faces in strips while the cube turns, and flat when it rests.
- The strips.
- Turn on a link, on focus and on a drag.
- Styles.
Navigation on a ribbon
A <nav> with eight links to pages of this site, drawn along a moving curve. Drag sideways to pull the ribbon through. Tap a link to follow it, or long-press it for the browser's link menu.
Each link is drawn in strips 4 px wide, and each strip is turned to the angle of the curve at its place. The link's hit region is its whole box, turned to the angle at its middle.
Show the code
- Each link is
drawable. The<nav>isn't drawn. - Measure the curve, draw the band, then each link in strips.
- A drag pulls the ribbon. A tap is left to the link.
- Styles.
Slices between hr elements
One <article> with three <hr> elements. The paint handler reads where each <hr> is, cuts the article's picture there, and draws the four slices at different depths. Drag sideways to look from another side.
The article is one element and has one hit region, and the four slices are drawn with four transforms. On each pointerdown, before the browser picks the element for the tap, the page moves the region to the slice under the pointer.
Show the code
- One
drawablearticle. - Cut at each
<hr>and draw the slices, far ones first. - Move the hit region to the slice under the pointer.
- A draw with no alpha, outside a paint event.
- Styles.
Header that folds away
Scroll inside the frame. The <header> folds up as the article moves down, and unfolds as soon as the scroll turns back, wherever the reader is in the article.
The scroller is ordinary HTML outside the canvas. A touch that starts on a drawn element scrolls it, because the canvas and everything drawn in it are inside the scroller.
Show the code
- A scroller, a canvas that stays in place, a header and an article.
- Fold by the distance scrolled, and draw.
- The fold.
- The scroll length.
- Scroller styles.
- Styles.
Drawer cabinet from details
Four <details> elements with one name. Each <summary> is a drawer front. Tap one: the drawer comes out towards you and its content is the inside of the drawer. The controls inside work.
The open drawer is one element drawn in two parts: its body as ten rows that get wider towards the reader, and its summary under the body, larger. A closing drawer's body is drawn from a snapshot taken while it was open.
Show the code
- Four
<details name>elements in a form. - Draw the fronts, then the drawer that is out.
- Move the hit region to the part under the pointer.
- Styles.
Aside as a margin note on a string
Scroll inside the frame. Each <aside> hangs from a pin beside the paragraph it follows in the markup. A change in scroll speed swings it and stretches its string. Press a note to push it.
The aside is drawn turned about its pin with one drawElementImage() call under a rotation, so its hit region turns with it and the checkbox can be pressed while it swings.
Show the code
- Paragraphs and asides, each
drawable, in a scroller. - Draw the paragraphs in view, then each aside on its string. The scroll pushes them.
- Styles.
How it works
Each canvas holds the real elements as descendants marked drawable. A paint handler draws them with drawElementImage() under a transform, or in clipped pieces under several transforms. The call also moves the element's hit region to where it was drawn. Four techniques are used more than once:
- Strips. A 2D context has affine transforms only. Perspective (the cube, the inside of a drawer), a fold (the header) and a bend (the ribbon) are made by drawing the same element many times, each time clipped to a narrow strip with its own transform.
- One region, several pieces. An element has one hit region, at the place of its last draw. The article in slices and the open drawer are shown in pieces that no single transform covers. A
pointerdownlistener on the canvas, in the capture phase, finds the piece under the pointer and makes one draw of the element there withglobalAlpha = 0. That draw is allowed outside apaintevent and moves the region before the browser picks the target of the tap. - A canvas inside a scroller. The folding header and the margin notes need a scroll position. The canvas is
position: stickyin an ordinary scroller with a spacer under it, and draws the content at minusscrollTop. The browser scrolls it by touch, wheel and keyboard. - The element is the state. The cabinet reads
openon each paint and the notes read the scroll position. A closed<details>has no picture of its body, so the cabinet keeps acaptureElementImage()snapshot of each open drawer and closes the old snapshot when it takes a new one.
Show the code
- The paint loop shared by the six demos.
- Move a hit region without drawing.
- Run before the tap is handled.
- Each demo starts when its section comes near the screen.
- A lost context stops every demo.
- The elements are then shown as plain HTML.
- Styles for the plain HTML.
Live checks
The checks wait for a tap. Each one builds its own small canvas in a corner of the window, and none of them touches the demos above.
Findings
Measured in headless Chromium 157 on 2026-11-21, at 412 px wide with emulated touch, and at 1000 px wide with a mouse and a keyboard.
- An element has one hit region, and a canvas can move it before a tap is resolved. A call to
drawElementImage()withglobalAlpha = 0made in apointerdownlistener, outside anypaintevent, moved the region. A touch tap sent with no delay between touch start and touch end then pressed the button in the piece under the finger: in the slices (button, checkbox) and in the drawer body (checkbox, range input, button). - The same draw needs an attribute toggle after it.
elementFromPoint()at the same point still returned the old answer until an attribute on the element changed. The check "A draw with globalAlpha 0 outside a paint event" shows both answers. - Two other routes for the same job were tried on a test page.
updateElementGeometry()in thepointerdownlistener also worked. Asking for a paint and moving the region in the nextpaintevent was too late for a tap with no delay (the click went to the canvas) and worked for a tap held for 60 ms. - A canvas that is
position: stickyin a scroller is scrolled natively from its drawn content. A touch drag that started on a drawn paragraph scrolled the scroller, a wheel did too, and the page didn't move. A scroll raises nopaintevent, so the page asks for one in itsscrolllistener. An element taller than the canvas, inside the canvas, didn't add to the scroll length. - Landmarks and headings stay in the accessibility tree. Chromium's tree (read over the DevTools protocol) lists four regions named Overview, Plan, Sizes and Contact with their headings, the three
<nav>elements as navigation landmarks, and all eight ribbon links, including the faces that are turned away and the links that are outside the canvas. - Focus can drive the drawing. Tab from the first face moved focus into the second section, which was parked, and the
focusinlistener turned the cube to it. - A link drawn in turned strips is still a link. Its one hit region is its box turned to the angle of the curve. A click on it navigated. A drag of more than 8 px pulled the ribbon and didn't navigate.
offsetTopof an<hr>inside a positioneddrawablearticle gives the cut. A clipped draw of the article shows the rows between two cuts and nothing else.- A horizontal drag on a canvas with
touch-action: pan-yreaches the page, and a vertical one scrolls it. The drag turned the cube by two faces with no page scroll. A vertical swipe on the same face scrolled the page by the length of the swipe. - The open drawer hides the drawer below it. Its front is drawn over the next slot and takes the taps there. That matches the picture, and it means the hidden drawer can't be opened until the open one is closed or another visible one is tapped.
- Not verified: everything on a phone. In particular whether a real finger tap is resolved after the
pointerdownlistener has moved the region, the frame rate of the ribbon (about 100 clipped draws a frame), the long-press link menu on a ribbon link, scroll momentum inside the two scrollers and how it drives the notes, and what TalkBack announces on the cube.