@fusion.dev/helix-docs 0.244.2 → 0.246.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/metrics.mdx +281 -281
- package/content/motion.mdx +173 -1
- package/dist/pages.generated.js +1 -1
- package/dist/sources.generated.js +454 -282
- package/package.json +12 -12
package/content/motion.mdx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: The duration and easing tokens,
|
|
2
|
+
description: The duration and easing tokens, how components handle reduced motion, and the functions that move your own elements.
|
|
3
3
|
section: Foundations
|
|
4
4
|
title: Motion
|
|
5
5
|
---
|
|
@@ -126,6 +126,8 @@ While the page's motion is paused:
|
|
|
126
126
|
- A graph that `connectGraph` lays out stops where its notes stand, and its
|
|
127
127
|
three.js view stops turning.
|
|
128
128
|
- A map layer's `frames` stop on the frame they show.
|
|
129
|
+
- The 3D charts and `Heatmap` stand at their readings, and a growth or a move
|
|
130
|
+
already running ends where it was heading.
|
|
129
131
|
|
|
130
132
|
The choice is the page's, held on the document element as
|
|
131
133
|
`data-helix-motion="paused"`. Set it in your markup to start the page paused,
|
|
@@ -218,6 +220,39 @@ does not hold. The mark on the end of a line rides with it. Safari does not
|
|
|
218
220
|
transition a path's shape, so lines, areas, points, and the mark on a line's
|
|
219
221
|
end there take their new place at once.
|
|
220
222
|
|
|
223
|
+
## 3D charts that grow in and follow their readings
|
|
224
|
+
|
|
225
|
+
The 3D charts draw their own marks, in SVG and through three.js, so their
|
|
226
|
+
motion runs in script. They are `Spatial Bar Chart`, `Spatial Scatter Chart`,
|
|
227
|
+
`Spatial Ribbon Chart`, `Spatial Surface Chart`, `Spatial Treemap`, and
|
|
228
|
+
`Spatial Heatmap`. Each mark is known by its name, such as a bar's category
|
|
229
|
+
and series, and a new table is matched against the marks drawn:
|
|
230
|
+
|
|
231
|
+
- A mark both tables hold moves from its old reading to its new one, and
|
|
232
|
+
slides to its new place.
|
|
233
|
+
- A mark only the new table holds grows from the floor.
|
|
234
|
+
- A mark the new table drops shrinks to the floor, and then goes.
|
|
235
|
+
|
|
236
|
+
The value axis eases to its new range, so a bar does not jump when the scale
|
|
237
|
+
changes, and its numbers are the new ones from the start. A surface whose grid
|
|
238
|
+
changed shape cannot be matched place for place, and takes its new shape at
|
|
239
|
+
once. A three.js drawing draws each frame the chart works out, and holds its
|
|
240
|
+
view still while the marks move.
|
|
241
|
+
|
|
242
|
+
A move takes `--<family>-move-duration` along `--<family>-move-easing`, such as
|
|
243
|
+
`--spatial-bar-chart-move-duration`. The styled tier sets them to
|
|
244
|
+
`--helix-duration-normal` and `--helix-easing-decelerate`, as the flat charts
|
|
245
|
+
move. The headless tier sets neither, so a new table is drawn at once there.
|
|
246
|
+
|
|
247
|
+
`grow` grows the marks in the first time the chart comes into view, each
|
|
248
|
+
category or column a little after the one before it, and `grow-again` grows
|
|
249
|
+
them again each time the chart comes back into view. The growth keeps its own
|
|
250
|
+
timing, a second for each mark, because the page asked for it by name. Under
|
|
251
|
+
`grow`, a later table grows the marks it adds the same way. A `Heatmap` takes
|
|
252
|
+
`grow` too: each cell starts empty and steps up through the tones to its own,
|
|
253
|
+
a column at a time. Its cells already take a new color through the
|
|
254
|
+
stylesheet, so it reads no move hooks.
|
|
255
|
+
|
|
221
256
|
## Starting styles and view transitions
|
|
222
257
|
|
|
223
258
|
Overlays use `@starting-style` to animate in. It sets a starting value and needs
|
|
@@ -270,3 +305,140 @@ It names the way for the length of the move, changes the page at once under
|
|
|
270
305
|
reduced motion or where the browser has no view transitions, and rejects
|
|
271
306
|
where the change does. To keep a header still while the rest of the page
|
|
272
307
|
moves, give it a `view-transition-name` of its own on every page.
|
|
308
|
+
|
|
309
|
+
## Motion on your own elements
|
|
310
|
+
|
|
311
|
+
Four functions in `@fusion.dev/helix-core` give elements you write yourself
|
|
312
|
+
the motion Helix's own families have, with no component around them:
|
|
313
|
+
|
|
314
|
+
- `moveItems` slides the items of a list to their new places.
|
|
315
|
+
- `trackIndicator` sends one mark from item to item.
|
|
316
|
+
- `countTo` counts a figure to a new number.
|
|
317
|
+
- `followPointer` writes where a mouse or pen is over an element.
|
|
318
|
+
|
|
319
|
+
Each one works on any element, in any framework, and needs no Helix
|
|
320
|
+
stylesheet. Times and curves default to the tokens above, and to the values
|
|
321
|
+
those tokens hold where the page does not load them. Under reduced motion
|
|
322
|
+
nothing moves, the figure changes at once, and the pointer is not followed.
|
|
323
|
+
`moveItems`, `followPointer`, and `trackIndicator` return the way to stop.
|
|
324
|
+
|
|
325
|
+
### Items that move
|
|
326
|
+
|
|
327
|
+
`moveItems` watches an element's children. When you or your framework add,
|
|
328
|
+
remove, reorder, or hide them, each item slides from its old place to its new
|
|
329
|
+
one, and an item you add fades in:
|
|
330
|
+
|
|
331
|
+
```js
|
|
332
|
+
import { moveItems } from '@fusion.dev/helix-core'
|
|
333
|
+
|
|
334
|
+
const stop = moveItems(document.querySelector('#tasks'), {
|
|
335
|
+
leaving: document.querySelector('#tasks-box'),
|
|
336
|
+
})
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
| Option | Default |
|
|
340
|
+
| --- | --- |
|
|
341
|
+
| `items`, a selector or a function returning the items | the element's children |
|
|
342
|
+
| `duration`, in milliseconds, as a time, or as a custom property | `--helix-duration-normal` |
|
|
343
|
+
| `easing`, a curve or a custom property | `--helix-easing-standard` |
|
|
344
|
+
| `leaving`, a positioned box around the element | none, so an item that leaves is gone at once |
|
|
345
|
+
| `arriveIntoEmpty`, so the first item into an empty list fades in | `false` |
|
|
346
|
+
|
|
347
|
+
A copy of an item that leaves fades out where it was, in the `leaving` box.
|
|
348
|
+
The copy never joins the element's own children, which your framework
|
|
349
|
+
manages, so give the box `position: relative` and put the list inside it.
|
|
350
|
+
When every item is new at once, as when a framework draws the whole list
|
|
351
|
+
again, the list appears without moving.
|
|
352
|
+
|
|
353
|
+
### A mark that travels
|
|
354
|
+
|
|
355
|
+
`trackIndicator` places one mark on the item that is marked now, and places it
|
|
356
|
+
again whenever an attribute inside the element changes, an item arrives or
|
|
357
|
+
leaves, or the element changes size:
|
|
358
|
+
|
|
359
|
+
```js
|
|
360
|
+
import { trackIndicator } from '@fusion.dev/helix-core'
|
|
361
|
+
|
|
362
|
+
trackIndicator(document.querySelector('nav'), {
|
|
363
|
+
active: '[aria-current="page"]',
|
|
364
|
+
indicator: document.querySelector('nav .mark'),
|
|
365
|
+
})
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
It writes four custom properties on the mark: `--indicator-x`,
|
|
369
|
+
`--indicator-y`, `--indicator-inline-size`, and `--indicator-block-size`.
|
|
370
|
+
Your stylesheet moves the mark with them, so its transition is the move:
|
|
371
|
+
|
|
372
|
+
```css
|
|
373
|
+
nav {
|
|
374
|
+
position: relative;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
nav .mark {
|
|
378
|
+
block-size: var(--indicator-block-size, 0);
|
|
379
|
+
inline-size: var(--indicator-inline-size, 0);
|
|
380
|
+
inset-block-start: 0;
|
|
381
|
+
inset-inline-start: 0;
|
|
382
|
+
opacity: 0;
|
|
383
|
+
position: absolute;
|
|
384
|
+
transition:
|
|
385
|
+
translate var(--helix-duration-normal) var(--helix-easing-emphasized),
|
|
386
|
+
inline-size var(--helix-duration-normal) var(--helix-easing-emphasized),
|
|
387
|
+
opacity var(--helix-duration-fast);
|
|
388
|
+
translate: var(--indicator-x, 0) var(--indicator-y, 0);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
nav .mark[data-placed] {
|
|
392
|
+
opacity: 1;
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
`data-placed` is on the mark once it has a place, so it fades in where it
|
|
397
|
+
belongs. `data-moving` is on it while it travels. With nothing marked, the
|
|
398
|
+
mark loses `data-placed`. Call `place()` on what it returns after a change it
|
|
399
|
+
cannot see, such as a new stylesheet, and `stop()` to end it.
|
|
400
|
+
|
|
401
|
+
### A figure that counts
|
|
402
|
+
|
|
403
|
+
`countTo` counts the number an element shows to a new one, and resolves once
|
|
404
|
+
the new figure is written:
|
|
405
|
+
|
|
406
|
+
```js
|
|
407
|
+
import { countTo } from '@fusion.dev/helix-core'
|
|
408
|
+
|
|
409
|
+
await countTo(document.querySelector('#revenue'), 1284)
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
It counts from the number last counted to, or from the number the element's
|
|
413
|
+
text reads. Pass `from` the first time for a figure written with grouping in
|
|
414
|
+
another language. The figure is written in the element's language, or with
|
|
415
|
+
`format`, which takes the number and returns its text. The count takes
|
|
416
|
+
`--helix-duration-slow` along `--helix-easing-decelerate`, and a new count
|
|
417
|
+
started during one carries on from the figure drawn.
|
|
418
|
+
|
|
419
|
+
The element's text changes on every frame, so keep it out of a live region and
|
|
420
|
+
tell screen reader users the new number another way.
|
|
421
|
+
|
|
422
|
+
### Following the pointer
|
|
423
|
+
|
|
424
|
+
`followPointer` writes `--pointer-x` and `--pointer-y` on an element while a
|
|
425
|
+
mouse or pen is over it, each from -1 to 1, with 0 and 0 in the middle. A
|
|
426
|
+
right-to-left page mirrors `--pointer-x`. The two go when the pointer leaves,
|
|
427
|
+
so give them `0` as the fallback:
|
|
428
|
+
|
|
429
|
+
```js
|
|
430
|
+
import { followPointer } from '@fusion.dev/helix-core'
|
|
431
|
+
|
|
432
|
+
followPointer(document.querySelector('.card'))
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
```css
|
|
436
|
+
.card {
|
|
437
|
+
rotate: x calc(var(--pointer-y, 0) * -6deg);
|
|
438
|
+
transition: rotate var(--helix-duration-normal) var(--helix-easing-standard);
|
|
439
|
+
}
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
`data-following` is on the element while the two are written. A touch is not
|
|
443
|
+
followed, since a finger is on the element only while it presses. Pass `moved`
|
|
444
|
+
and `left` to hear the same positions in script.
|
package/dist/pages.generated.js
CHANGED
|
@@ -138,7 +138,7 @@ export const docPages = [
|
|
|
138
138
|
title: 'Metrics',
|
|
139
139
|
},
|
|
140
140
|
{
|
|
141
|
-
description: 'The duration and easing tokens,
|
|
141
|
+
description: 'The duration and easing tokens, how components handle reduced motion, and the functions that move your own elements.',
|
|
142
142
|
section: 'Foundations',
|
|
143
143
|
slug: 'motion',
|
|
144
144
|
title: 'Motion',
|