Live minimap of a page

A scrolling column of articles inside a canvas. Each <article> is drawn twice: at full size in the reading area, and at about a sixth of its size in the strip on the right. The strip is drawn from the same live elements, so typing in the note, running the build or adding an article changes it at once. Scroll the column by touch or wheel. Drag or tap in the strip to move the view. Overview flies every article out to a grid, and a tap on one flies back to it.

Release notes

Version 4.2 moves the editor into a worker and cuts first load by a third.

Your note

Type here and watch the strip.

Build

idle

Traffic

Theme

The colour applies to this article. The strip shows it too.

Changelog

4.1 added offline drafts. 4.0 replaced the sync engine. 3.9 was the last version with the old toolbar.

3.8 fixed pasted tables. 3.7 added comments.

 

Show the code two draws per article, the rail, the overview
  1. The markup. A scroll container, articles with drawable inside it, and an empty rail element for the strip.
  2. On paint. Draw every article small in the strip, then draw the ones in view at full size. The last draw of an element decides where its input goes.
  3. Scrolling. The browser doesn't scroll a container that isn't drawable, so the page turns wheel and touch input into scrollTop.
  4. The rail. Pointer and key input on the strip sets scrollTop.
  5. Overview. A tap on an article in the grid scrolls to it.
  6. The paint loop, put(), hitOnly() and park().
  7. Styles.

How it works

Every article has drawable. The scroll container around them is laid out and scrolls, and has no picture. The picture of an article is the whole article, also when it's scrolled out of view. That's what lets the strip show the full page.

On each paint event the canvas draws the rail, then every article at the strip's scale, then a frame for the part in view. After that it draws the articles that are in view at full size, at offsetTop - scrollTop, clipped to the reading area. An element's hit region is where it was drawn last, so articles in view take input in the reading area. An article out of view was last drawn in the strip. Its hit region is shrunk to a point with updateElementGeometry(), so the strip's input goes to the rail.

Scrolling has two routes, and the menu under the demo switches between them.

Route 1, the default: the scroll container isn't drawable. Chromium then doesn't scroll it for a wheel or a touch drag. The input goes to the page. The events still reach the container, because they bubble from the article that was hit. The page sets scrollTop from the wheel delta and from touch movement, keeps moving after the finger lifts, and passes what is left over to the page when the container is at an end. Page Up and Page Down scroll it without help.

Route 2: the scroll container has drawable too and is drawn with no alpha, which gives it a hit region. The browser scrolls it. The cost is in the pictures. An article is now a drawable element inside a drawable element, and Chromium records only the part of it that is inside the container's box at that moment. An article that changes while it's half out of view loses the hidden half in the strip, and the hole stays until the article changes again while fully in view. Switch to this route, scroll an article half out, press "New numbers" and look at the strip.

The rail is an empty element with touch-action: none, role="scrollbar" and a tab stop. Its hit region covers the strip. A drag on it sets scrollTop. Arrow keys, Page Up and Page Down work when it has focus.

The minimap covers the articles in this canvas only. An element can be drawn only into the canvas it is inside, so a minimap of the whole document would need the whole document inside one canvas.

Live checks

These run on their own small scroll containers in the corner of the window.

Findings