@diegopluna/narvi 0.3.9 → 0.3.10

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.
@@ -253,8 +253,16 @@
253
253
  [stylex.when.ancestor(':focus-within', tabStripTabMarker)]: 0
254
254
  }
255
255
  },
256
- // Where nothing hovers, the open tab shows its close button in the icon's place
257
- leadIconSelected: { opacity: { default: 0, [media.hover]: { default: 1 } } },
256
+ // Where nothing hovers, the open tab shows its close button in the icon's place; where
257
+ // something does, its icon steps aside under the pointer as any tab's does. The whole
258
+ // rule again, since a style replaces the one before it rather than merging with it
259
+ leadIconSelected: {
260
+ opacity: {
261
+ default: 0,
262
+ [media.hover]: { default: 1, [stylex.when.ancestor(':hover', tabStripTabMarker)]: 0 },
263
+ [stylex.when.ancestor(':focus-within', tabStripTabMarker)]: 0
264
+ }
265
+ },
258
266
  leadMark: { gridArea: '1 / 1' },
259
267
  start: {
260
268
  position: 'absolute',
@@ -18,6 +18,11 @@
18
18
  * of the display. A spinner is the exception: it has to turn smoothly, so it is
19
19
  * a plain rotation, and only the pausing applies to it.
20
20
  *
21
+ * Each time one starts to run, it is set to where the page's clock puts it, as if every
22
+ * animation had started as the page loaded. So animations alike move together however late each
23
+ * came into view: the spinners of a list of rows turn as one, rather than each from the moment
24
+ * its row scrolled in.
25
+ *
21
26
  * Without this the animation runs: the property's fallback is `running`.
22
27
  *
23
28
  * ```svelte
@@ -2,9 +2,24 @@ const watched = new Map();
2
2
  let observer = null;
3
3
  // Hidden by the host's word, whatever the document says
4
4
  let hiddenByHost = false;
5
+ // Each of the element's animations to where the page's clock puts it: its time since the page
6
+ // loaded, within one cycle. Seeking a CSS animation leaves its play state to the stylesheet.
7
+ function align(element) {
8
+ const now = document.timeline.currentTime;
9
+ if (typeof now !== 'number')
10
+ return;
11
+ for (const animation of element.getAnimations()) {
12
+ const { duration } = animation.effect?.getComputedTiming() ?? {};
13
+ if (typeof duration === 'number' && duration > 0)
14
+ animation.currentTime = now % duration;
15
+ }
16
+ }
5
17
  function apply(item) {
6
18
  const running = item.inView && !document.hidden && !hiddenByHost;
7
19
  item.element.style.setProperty('--narvi-play', running ? 'running' : 'paused');
20
+ if (running && !item.running)
21
+ align(item.element);
22
+ item.running = running;
8
23
  }
9
24
  function applyAll() {
10
25
  for (const item of watched.values())
@@ -48,7 +63,7 @@ export const whileVisible = (element) => {
48
63
  });
49
64
  document.addEventListener('visibilitychange', applyAll);
50
65
  }
51
- const item = { element, inView: false };
66
+ const item = { element, inView: false, running: false };
52
67
  watched.set(element, item);
53
68
  // Paused until the observer has looked, which it does before the next frame is drawn
54
69
  apply(item);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diegopluna/narvi",
3
- "version": "0.3.9",
3
+ "version": "0.3.10",
4
4
  "packageManager": "pnpm@12.18.0",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -12,7 +12,7 @@ metadata:
12
12
  Grid, and Narvi's conventions for colour, labels and copy.
13
13
  type: core
14
14
  library: '@diegopluna/narvi'
15
- library_version: '0.3.9'
15
+ library_version: '0.3.10'
16
16
  requires:
17
17
  - setup
18
18
  sources:
@@ -268,7 +268,7 @@ your own for it. `outputLabels` renames it.
268
268
 
269
269
  - `sx()`, `classes()` and the `Sx` type: see the `styling` skill.
270
270
  - `resolveColor()` and `resolveRgba()`: see the `theming` skill.
271
- - `whileVisible`: an attachment that runs an animation that never ends only while it can be seen, with `animationPlayState: play.whileVisible` from the tokens. Step the animation itself.
271
+ - `whileVisible`: an attachment that runs an animation that never ends only while it can be seen, with `animationPlayState: play.whileVisible` from the tokens. Step the animation itself. Each time it starts to run it is set to the page's clock, so animations alike, such as the spinners down a list, move together; don't stagger them by hand.
272
272
  Shimmer, Skeleton, Progress and Markdown's caret run on it, stepped. Spinner pauses with it
273
273
  too, but is not stepped: it is a CSS animation of `rotate`, one turn in 600ms, so it stays smooth.
274
274
  - `setPageHidden(hidden)`: tells Narvi the host has hidden the page where the document cannot
@@ -12,7 +12,7 @@ metadata:
12
12
  patching the DOM, and decide which links and images text from a model may load.
13
13
  type: core
14
14
  library: '@diegopluna/narvi'
15
- library_version: '0.3.9'
15
+ library_version: '0.3.10'
16
16
  requires:
17
17
  - setup
18
18
  sources:
@@ -11,7 +11,7 @@ metadata:
11
11
  4 when the app uses it.
12
12
  type: lifecycle
13
13
  library: '@diegopluna/narvi'
14
- library_version: '0.3.9'
14
+ library_version: '0.3.10'
15
15
  sources:
16
16
  - src/lib/vite.ts
17
17
  - src/lib/base.css
@@ -12,7 +12,7 @@ metadata:
12
12
  hover, motion and forced-colour preferences.
13
13
  type: core
14
14
  library: '@diegopluna/narvi'
15
- library_version: '0.3.9'
15
+ library_version: '0.3.10'
16
16
  requires:
17
17
  - setup
18
18
  sources:
@@ -101,7 +101,8 @@ package root) breaks them.
101
101
  its hairline takes the ring and halo while the field inside is typed into, as a text field's
102
102
  does. Don't redraw either with `:focus-visible` styles of your own.
103
103
  - `play.whileVisible`: the `animationPlayState` for an animation that never ends. Attach
104
- `whileVisible` (from the package root) to its element and it runs only while it can be seen.
104
+ `whileVisible` (from the package root) to its element and it runs only while it can be seen,
105
+ in step with the page's other animations of the same length.
105
106
  Step such an animation (`steps(30)` over two seconds) so it costs a few frames a second.
106
107
  - `setPageHidden(hidden)` (from the package root) is the host's word that the page is out of
107
108
  sight where `document.hidden` stays false, as in an Electron window with background
@@ -11,7 +11,7 @@ metadata:
11
11
  menus and dialogs, and resolve token colours for drawing code that cannot read CSS variables.
12
12
  type: core
13
13
  library: '@diegopluna/narvi'
14
- library_version: '0.3.9'
14
+ library_version: '0.3.10'
15
15
  requires:
16
16
  - setup
17
17
  sources: