17 ideas from the element catalogue, built

The element catalogue measures what each HTML element does inside a drawable canvas and lists things to build with it. I built the first 17 of them on this page. Each one keeps the real element: the form control still holds the value, the link is still a link, and the canvas only decides where and how the element is drawn. Under each demo is what the element still does without help and what the page had to add.

Findings

Picker wheel from <select multiple>

Twelve <option> elements drawn round a drum. Drag or use the mouse wheel to turn it. Tap an option to select it; with a mouse, Ctrl or Shift selects several, as in any list box.

The select is never drawn, only its options. Selection, the form value, arrow keys and type-ahead are the list box's own. The page adds the turning and moves an option's hit region away when it is on the back of the drum.

Show the code
  1. Mark each option drawable.
  2. Draw each option at its angle. The squash is a vertical scale, so the hit region is squashed with it.
  3. Styles.

Mixing desk from rotated <input type="range">

Five range inputs, laid out horizontally and drawn turned a quarter turn. Drag a fader up and down. The button starts five tones whose volumes are the input values.

With a mouse the browser maps the drag through the rotation: moving up raises the value. With touch, a tap on the track is mapped too, but a drag isn't followed. Chrome tests the direction of a touch drag on screen to tell a slider drag from a scroll, and for a horizontal slider a vertical drag fails that test. A slider drawn at 17 degrees still drags by touch; at 90 degrees the page has to set the value from the pointer.

Show the code
  1. Five range inputs in the canvas.
  2. Rotate, then draw.
  3. touch-action: none on the inputs.
  4. Set the value for touch drags.

Step sequencer from checkboxes

A form with four fieldsets of eight checkboxes. Tap pads to set the pattern, then Play. Clear is a type="reset" button, so it restores the pattern in the markup.

The whole form is one picture and every checkbox in it is hit where it is drawn. The canvas adds the moving column and the rings. The pattern is ordinary form data.

Show the code
  1. The form. The script adds one fieldset of checkboxes per sound.
  2. Draw the column behind the form and the rings in front.
  3. Checkboxes styled as pads.

<textarea> as a CRT terminal

Tap the screen and type. The textarea is drawn in 24 bands to bulge the picture, then again blurred for the glow, with scan lines on top.

The caret, selection and on-screen keyboard are the textarea's. Input uses the flat rectangle, so near the left and right edges a tap lands up to 6 pixels from the bent picture.

Show the code
  1. A textarea in the canvas.
  2. Bands, glow, scan lines, then an invisible flat draw for input.
  3. Styles.

<dialog> in the canvas with a drawn backdrop

Tick some files and press Delete. The dialog is opened with show(), so it stays a child of the canvas. The canvas blurs the page behind it and draws the backdrop.

Files

Delete files?

This cannot be undone.

showModal() puts a dialog in the top layer, which the page paints and the canvas can't draw. With show() the canvas draws it, and the page supplies what modal gives for free: inert on the content behind, Escape, and returning focus.

Show the code
  1. The page content and the dialog are both children of the canvas.
  2. Filter the page, draw the backdrop, draw the dialog.
  3. Opening, closing and focus.

Popover call-outs anchored to drawn buttons

Three buttons drawn on a camera that the canvas moves. Each opens a popover that CSS positions above its button. Tap a number to open or close its call-out.

Lens. 35 mm, f/1.8.
Shutter button. Half press to focus.
Screen. Tilts up 90 degrees.

The popovers are outside the canvas, in the top layer. Anchor positioning uses the place where the button was last drawn, so they follow with no script. position-try-fallbacks flips one below when it would leave the viewport.

Show the code
  1. Buttons in the canvas, popovers outside it.
  2. The positioning is two CSS declarations.
  3. Draw each button at its point on the drawing.

inert on children that aren't drawn

Three panels are children of the canvas and one is drawn. Press Next a few times, then untick the box and try again, with Tab as well if you have a keyboard.

Panel 1

Panel 2

Panel 3

An element that is no longer drawn keeps the hit region of its last draw and stays in the Tab order. Without inert, taps on the empty outlines reach hidden fields and Tab moves focus to controls nobody can see.

Show the code
  1. Three panels.
  2. Draw one, set inert on the rest.

Find-in-page moving a camera

The box shows one of twelve places laid out in a grid three wide. Search for lighthouse, ferry or heron with the form, or with the browser's own find-in-page. Some text is in hidden="until-found" parts: try tide table.

Harbour

Fishing boats land here before dawn. The ferry to the island leaves from the east quay.

Lighthouse

The lighthouse on the north rock has shown a white light every ten seconds since 1881.

Open on Sundays.

Salt marsh

A heron stands in the creek most mornings. Samphire grows along the edge in July.

Old town

Four streets and a market square. The bakery sells out of rye bread by nine.

Station

Two platforms. Trains to the city run hourly and take fifty minutes.

Allotments

Sixty plots behind the railway. Rhubarb, beans and one very large pumpkin.

Quarry

Closed in 1962 and now a lake. Swimming is allowed from the wooden jetty.

Windmill

The windmill grinds flour two days a week. The sails are turned by hand to face the wind.

Library

A reading room with a stove. The map drawer holds charts of every channel in the estuary.

Bridge

An iron swing bridge. It opens for the grain barge and for the ferry in winter.

Dunes

Marram grass and a boardwalk to the beach. Skylarks nest here from April.

Observatory

A small dome with a brass telescope. On clear nights the lighthouse beam crosses the field.

The view is a scroll container. When something scrolls it to a match, the page takes the scroll back and replays it as a flight with a zoom. The form on this page selects the match and scrolls to it, which is tested. The browser's find-in-page should cause the same scroll, and open the until-found parts with a beforematch event, but a script can't open it, so that route is untested here.

Show the code
  1. Catch the scroll, undo it, fly there.
  2. A small view over a large grid.

MathML terms moving between lines

Five lines of a solved equation, each a <math> element. Press Next. A term that is in both lines travels from its old place to its new one.

2x+3=11
2x=11−3
2x=8
x=82
x=4

getBoundingClientRect() works on MathML tokens inside a drawn element, which is all the animation needs: each term is the line's picture clipped to that token's box and moved. Between animations the current line is drawn whole, so its text can be selected.

Show the code
  1. Give the same data-k to a term in each line it appears in.
  2. Move a clipped piece of the old line and a clipped piece of the new line.

<video controls> on a drawn screen

Press play on the video's own controls. The canvas draws the video three times: blurred and enlarged as light on the wall, upside down as a reflection, and last as the screen.

The native controls and the captions are part of the element's picture, so they appear in the glow and the reflection as well. The controls take taps on the last copy drawn. A playing video fires paint for every frame, so there's no animation loop.

Show the code
  1. A video with controls and a caption track.
  2. Three draws under one shear.

Image map on a tilted floor plan

An <img usemap> drawn turned 45 degrees and squashed. Tap a room. Each room is an <area>, and Tab moves between them.

Floor plan of a flat with five rooms Kitchen Living room Bathroom Hall Bedroom No room chosen

The browser hit tests the <area> rectangles through the rotation and the squash. The click event's target is the area. The raised room is the same image drawn again through a clip.

Show the code
  1. An image, a map and five areas.
  2. Draw the floor, raise the chosen room, place the hit region on the floor.

Cover flow from <ul>

Seven list items. Swipe sideways, tap a cover at the side, or use Tab and the arrow keys. The button on the front cover is a real button.

  • Tidal Flats

    The Waders

  • Signal Fire

    Northern Line

  • Night Bus

    Kiosk

  • Allotment Songs

    Runner Bean

  • Sodium Light

    Ring Road

  • Low Sun

    Harvest Radio

  • Shipping News

    Dogger

The <ul> isn't drawn. Each <li> has its own picture and its own hit region, so a tap on a side cover arrives at that item with no arithmetic in the page. The list is still a list of seven items to a screen reader.

Show the code
  1. A list with drawable on each item.
  2. Draw each item with its own shear, far ones first.
  3. Styles.

Radial menu from <menu>

Press Tools. The eight items of a <menu> fly out round the button. Arrow keys move between them and Escape closes.

  • Each button is hit where it lands, part-way through the animation too. While the menu is closed nothing is drawn for it, so the menu is inert.

    Show the code
    1. A button and a menu.
    2. Place each item on the circle.
    3. Styles.

    Table cells raised into a bar chart

    A table of numbers. Each cell is drawn on top of a bar as tall as its number. Tap a number and type a new one. The slider lays the table flat again.

    MonTueWedThu
    Web12302241
    App25183528
    Shop8142016

    Table cells with drawable stay table cells: the layout is still the table's, and each one can be drawn somewhere else. The hit region of a cell is on top of its bar, so the caret goes where the number is shown.

    Show the code
    1. A table with drawable on every cell.
    2. Stack the cell's outline, then draw the cell on top.
    3. Styles.

    <ins> and <del> animated as a change

    One paragraph with deletions and insertions marked up. Press play, or drag the slider. The deleted words are struck through and fade, the text reflows, and the inserted words are wiped in.

    The canvas draws a bitmap copy ofthe live element, so it cannot be clicked and it still takes clicks. Text in it is lost tocan be found by find-in-page.

    getClientRects() gives one box per line of each <del> and <ins>. The article is drawn once with those boxes clipped out, then once per box with its own alpha or wipe. The markup still says what was deleted and inserted.

    Show the code
    1. The paragraph.
    2. Draw the unchanged text, then each changed box.
    3. CSS picks which words are laid out.

    An editable <style> element

    The text box is a <style> element with display: block and contenteditable. Change a value, for example the colour or rotate. The badge above it restyles as you type.

    Sale 20%

    The browser reparses the sheet on every edit, and both elements fire paint, so there's no editor code. The rules apply to the whole document, which is why this one is scoped to #stylePreview.

    Show the code
    1. A preview and a style element, both drawable.
    2. Draw both.
    3. Make the style element visible.

    LED ticker from <marquee>

    A <marquee> drawn enlarged and cut into dots. The browser scrolls the text. The link in it can be tapped as it goes past.

    HTML in canvas: the browser scrolls this text. See marquee in the catalogue

    A marquee fires paint each time it moves, so the canvas has no timer. The dots are a pattern applied with destination-in. The hit region of the marquee and its link is the enlarged picture.

    Show the code
    1. A marquee.
    2. Draw, mask with dots, add the panel behind and the glow in front.

    The shared paint loop

    Every demo on this page uses the same 40 lines to size its canvas, listen for paint and stop when it's off screen.

    Show the code
    1. mount(), put(), hitOnly() and park().