@blotch/angular-lynx 22.2.2 → 22.2.4

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/README.md CHANGED
@@ -20,18 +20,44 @@ Then work as in any Angular app: `ng serve`, `ng build`, `ng test`, and `ng gene
20
20
 
21
21
  - Standalone components with signals, `@if`/`@for`/`@switch`, DI, and pipes
22
22
  - Zoneless change detection — signals as the primary reactivity model
23
- - Full Angular Router with in-memory navigation for Lynx
23
+ - Full Angular Router with in-memory navigation for Lynx, including `routerLink` and `routerLinkActive` on any element
24
24
  - Gestures — tap, pan, long-press, fling, pinch, rotation with composition
25
25
  - Animations — CSS transitions, keyframes, and programmatic `animate()` API
26
26
  - Content projection, portals, `@defer`, and lazy-loaded routes
27
- - Tailwind CSS via `@lynx-js/tailwind-preset`
27
+ - Tailwind CSS 4, with the build rewriting its CSS for Lynx (or Tailwind CSS 3 with `@lynx-js/tailwind-preset`)
28
28
 
29
29
  ## Documentation
30
30
 
31
- Full docs and guides at [angularlynx.dev](https://angularlynx.dev).
31
+ Full docs and guides at [angularlynx.js.org](https://angularlynx.js.org).
32
32
 
33
33
  ---
34
34
 
35
+ ## Routing
36
+
37
+ `provideRouter()` from `@blotch/angular-lynx` sets up Angular's Router with in-memory history. Everything else comes from `@angular/router`, as on the web, `routerLink` and `routerLinkActive` included:
38
+
39
+ ```typescript
40
+ import { Component } from '@angular/core';
41
+ import { RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
42
+ import { LYNX_ELEMENTS } from '@blotch/angular-lynx';
43
+
44
+ @Component({
45
+ selector: 'app-root',
46
+ imports: [LYNX_ELEMENTS, RouterOutlet, RouterLink, RouterLinkActive],
47
+ template: `
48
+ <view routerLink="/settings" routerLinkActive="active">
49
+ <text>Settings</text>
50
+ </view>
51
+ <router-outlet />
52
+ `,
53
+ })
54
+ export class App {}
55
+ ```
56
+
57
+ - A tap on the element navigates: the renderer delivers Lynx's `tap` to `click` listeners, as Lynx for Web does, and `RouterLink` listens for `click`.
58
+ - While the link's route is active, `routerLinkActive` adds its classes and `LYNX_ELEMENTS` adds `selected` to the element's `accessibility-traits`, keeping its own (`LynxRouterLinkActive`). On a component's host, list `LynxRouterLinkActive` in `hostDirectives` next to `RouterLinkActive`.
59
+ - Event handlers can navigate directly, with `Router.navigate()` or `Location.back()`.
60
+
35
61
  ## Animation API
36
62
 
37
63
  Three animation approaches are available, all running natively on the Lynx engine.
@@ -103,25 +129,23 @@ export class ExampleComponent {
103
129
  #animation: LynxAnimation | null = null;
104
130
 
105
131
  runAnimation(): void {
106
- setTimeout(() => {
107
- const el = this.boxRef();
108
- if (!el) return;
109
-
110
- // Cancel previous animation before starting a new one.
111
- this.#animation?.cancel();
112
-
113
- this.#animation = el.nativeElement.animate(
114
- [
115
- { transform: 'scale(1)', opacity: 1 },
116
- { transform: 'scale(1.3)', opacity: 0.7 },
117
- { transform: 'scale(1)', opacity: 1 },
118
- ],
119
- {
120
- duration: 600,
121
- easing: 'ease-in-out',
122
- },
123
- );
124
- }, 0);
132
+ const el = this.boxRef();
133
+ if (!el) return;
134
+
135
+ // Cancel previous animation before starting a new one.
136
+ this.#animation?.cancel();
137
+
138
+ this.#animation = el.nativeElement.animate(
139
+ [
140
+ { transform: 'scale(1)', opacity: 1 },
141
+ { transform: 'scale(1.3)', opacity: 0.7 },
142
+ { transform: 'scale(1)', opacity: 1 },
143
+ ],
144
+ {
145
+ duration: 600,
146
+ easing: 'ease-in-out',
147
+ },
148
+ );
125
149
  }
126
150
  }
127
151
  ```
@@ -181,4 +205,4 @@ Available events: `animationstart`, `animationend`, `animationcancel`, `animatio
181
205
  #### Important Notes
182
206
 
183
207
  - The `animate()` API is **main-thread only**. Calling it on the background thread throws an error.
184
- - Wrap `animate()` calls inside `setTimeout(() => { ... }, 0)` when triggered from Lynx event callbacks to avoid mutating the element tree inside a worklet.
208
+ - Call `animate()` straight from an event handler; it doesn't need a `setTimeout`.