@ssgoi/angular 6.3.0 → 6.5.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/README.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  Angular bindings for SSGOI that give any Angular 20+ app native-feeling page transitions powered by the `@ssgoi/core` animation engine.
4
4
 
5
+ try this: [ssgoi.dev](https://ssgoi.dev)
6
+
7
+ ## AI-Assisted Setup
8
+
9
+ Using Claude, Cursor, ChatGPT, or another AI assistant? Point it at:
10
+
11
+ ```
12
+ https://ssgoi.dev/llms.txt
13
+ ```
14
+
15
+ It has the full setup guide, every transition, the API, and troubleshooting — everything an agent needs to wire SSGOI into your app.
16
+
5
17
  ## Installation
6
18
 
7
19
  ```bash
@@ -15,7 +27,8 @@ yarn add @ssgoi/angular
15
27
  ## What You Get
16
28
 
17
29
  - `Ssgoi` directive (selector: `[ssgoi]`) that bootstraps the core transition context on the client and gracefully no-ops during SSR.
18
- - `SsgoiTransition` directive (selector: `[ssgoiTransition]`) that wires individual route containers into the transition system.
30
+ - `data-ssgoi-transition` route markers discovered automatically inside `[ssgoi]`.
31
+ - Deprecated `SsgoiTransition` directive (selector: `[ssgoiTransition]`) kept for backward compatibility.
19
32
  - `injectSsgoi()` helper and `SSGOI_CONTEXT` injection token for retrieving the transition context anywhere in your component tree.
20
33
  - Re-exported transition factories under `@ssgoi/angular/view-transitions`.
21
34
 
@@ -34,10 +47,11 @@ import { fade } from "@ssgoi/angular/view-transitions";
34
47
  standalone: true,
35
48
  imports: [RouterOutlet, Ssgoi],
36
49
  template: `
50
+ <!-- position: relative + z-index: 0 are required (the outgoing page is cloned with position:absolute) -->
37
51
  <div
38
52
  ssgoi
39
53
  [config]="ssgoiConfig()"
40
- style="position: relative; min-height: 100vh"
54
+ style="position: relative; z-index: 0; min-height: 100vh"
41
55
  >
42
56
  <router-outlet />
43
57
  </div>
@@ -50,18 +64,16 @@ export class AppComponent {
50
64
  }
51
65
  ```
52
66
 
53
- ### 2. Mark each routed view with `SsgoiTransition`
67
+ ### 2. Mark each routed view
54
68
 
55
69
  ```typescript
56
70
  import { Component } from "@angular/core";
57
- import { SsgoiTransition } from "@ssgoi/angular";
58
71
 
59
72
  @Component({
60
73
  selector: "app-home",
61
74
  standalone: true,
62
- imports: [SsgoiTransition],
63
75
  template: `
64
- <section [ssgoiTransition]="'/home'">
76
+ <section data-ssgoi-transition="/home">
65
77
  <h1>Home Page</h1>
66
78
  </section>
67
79
  `,
@@ -69,12 +81,12 @@ import { SsgoiTransition } from "@ssgoi/angular";
69
81
  export class HomeComponent {}
70
82
  ```
71
83
 
72
- The value you pass to `[ssgoiTransition]` should uniquely identify the view (commonly the route path).
84
+ The `data-ssgoi-transition` value should uniquely identify the view (commonly the route path).
73
85
 
74
86
  ## How It Works
75
87
 
76
- - `Ssgoi` wraps `createSggoiTransitionContext` from `@ssgoi/core` and injects it via `SSGOI_CONTEXT`. The directive guards against the server platform so SSR renders stay deterministic.
77
- - `SsgoiTransition` reads that context with `injectSsgoi()`, sets `data-ssgoi-transition` on the host, and subscribes the element to the core transition runner.
88
+ - `Ssgoi` wraps `createSggoiTransitionContext` from `@ssgoi/core`, injects it via `SSGOI_CONTEXT`, and observes `data-ssgoi-transition` elements under the host. The directive guards against the server platform so SSR renders stay deterministic.
89
+ - The deprecated `SsgoiTransition` directive still sets `data-ssgoi-transition` and registers the host directly for backward compatibility.
78
90
 
79
91
  Because everything is driven by signals, Angular change detection stays minimal and the bundle remains fully tree-shakeable.
80
92
 
@@ -83,25 +95,48 @@ Because everything is driven by signals, Angular change detection stays minimal
83
95
  - `Ssgoi`
84
96
  - `config: SsgoiConfig` (input, optional) – global transition configuration. Uses `{}` as default.
85
97
  - `host: HostAnimation | undefined` (input, optional) – external playback host for debug tooling.
86
- - `SsgoiTransition`
87
- - `ssgoiTransition: string` (required input) – identifier for the target view/container.
98
+ - `data-ssgoi-transition` – identifier for the target view/container.
99
+ - `SsgoiTransition` is deprecated; use `data-ssgoi-transition` directly.
88
100
  - `injectSsgoi(): SsgoiContext` – returns the adapter context. During SSR it falls back to a no-op implementation so you can call it unconditionally.
89
101
 
90
102
  ## Available Transitions
91
103
 
92
- View-level factories:
104
+ Import view-level factories from `@ssgoi/angular/view-transitions`:
93
105
 
94
106
  ```typescript
95
107
  import {
96
108
  fade,
97
- scroll,
98
109
  drill,
99
- hero,
100
110
  slide,
111
+ scroll,
112
+ axis,
113
+ sheet,
114
+ hero,
101
115
  zoom,
116
+ strip,
117
+ blind,
118
+ film,
119
+ rotate,
120
+ jaemin,
102
121
  } from "@ssgoi/angular/view-transitions";
103
122
  ```
104
123
 
124
+ - `fade()` - Calm cross-fade. Safe default for unrelated pages
125
+ - `drill()` - iOS-style hierarchical navigation (list → detail)
126
+ - `slide()` - Horizontal push for tabs / sequential flows
127
+ - `scroll()` - Vertical page scroll for onboarding / paginated views
128
+ - `axis()` - Material/Flutter shared-axis swap for sibling/tab routes
129
+ - `sheet()` - Bottom sheet that slides up (modal-like flows)
130
+ - `hero()` - Shared element transition (matching `data-hero-enter-key` / `data-hero-exit-key`)
131
+ - `zoom()` - Card-to-detail expansion (matching `data-zoom-enter-key` / `data-zoom-exit-key`)
132
+ - `strip()` - 3D Y-axis perspective flip
133
+ - `blind()` - Window-blinds wipe reveal
134
+ - `film()` - Cinematic shrink + tile (gallery / lightbox)
135
+ - `rotate()` - Card flip between siblings
136
+ - `jaemin()` - Playful rotated zoom for special moments
137
+
138
+ Each factory takes the unified config: `{ paths }` (symmetric), `{ enter, exit, type? }` (directional, e.g. `drill`/`sheet`), or `{ paths }` with order deciding direction (`slide`/`scroll`/`axis`).
139
+
105
140
  ## Sample Configuration
106
141
 
107
142
  ```typescript
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ssgoi/angular",
3
- "version": "6.3.0",
3
+ "version": "6.5.0",
4
4
  "description": "Angular bindings for SSGOI - Native app-like page transitions for Angular applications",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "types": "./dist/index.d.ts",
8
8
  "dependencies": {
9
- "@ssgoi/core": "^6.3.0"
9
+ "@ssgoi/core": "^6.5.0"
10
10
  },
11
11
  "peerDependencies": {
12
12
  "@angular/common": "^20.0.0",
package/src/lib/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { Ssgoi } from "./ssgoi.directive";
2
+ /** @deprecated Set `data-ssgoi-transition` directly on an element inside `[ssgoi]` instead. */
2
3
  export { SsgoiTransition } from "./ssgoi-transition.directive";
3
4
  export { injectSsgoi, SSGOI_CONTEXT } from "./context";
4
5
  export * from "./types";
@@ -10,6 +10,10 @@ import {
10
10
  import { isPlatformBrowser } from "@angular/common";
11
11
  import { injectSsgoi } from "./context";
12
12
 
13
+ /**
14
+ * @deprecated Set `data-ssgoi-transition` directly on the page boundary
15
+ * element inside `[ssgoi]` instead.
16
+ */
13
17
  @Directive({
14
18
  selector: "[ssgoiTransition]",
15
19
  standalone: true,
@@ -1,27 +1,24 @@
1
1
  import {
2
+ AfterViewInit,
2
3
  Directive,
4
+ ElementRef,
5
+ OnDestroy,
3
6
  input,
4
7
  forwardRef,
5
8
  PLATFORM_ID,
6
9
  inject,
7
10
  } from "@angular/core";
8
11
  import { isPlatformBrowser } from "@angular/common";
9
- import { createSggoiTransitionContext } from "@ssgoi/core/internal";
12
+ import {
13
+ createSggoiTransitionContext,
14
+ observeSsgoiTransitions,
15
+ } from "@ssgoi/core/internal";
10
16
  import type { HostAnimation } from "@ssgoi/core/internal";
11
17
  import type { SsgoiConfig, SsgoiContext } from "@ssgoi/core/types";
12
18
  import { SSGOI_CONTEXT } from "./context";
13
19
 
14
20
  function createSsgoiContext(component: Ssgoi): SsgoiContext | undefined {
15
- const platformId = inject(PLATFORM_ID);
16
-
17
- // Only create context in browser environment
18
- if (!isPlatformBrowser(platformId)) {
19
- // Return a no-op context for SSR
20
- return undefined;
21
- }
22
- return createSggoiTransitionContext(component.config(), {
23
- host: component.host(),
24
- });
21
+ return component.getContext();
25
22
  }
26
23
 
27
24
  @Directive({
@@ -35,7 +32,34 @@ function createSsgoiContext(component: Ssgoi): SsgoiContext | undefined {
35
32
  },
36
33
  ],
37
34
  })
38
- export class Ssgoi {
35
+ export class Ssgoi implements AfterViewInit, OnDestroy {
39
36
  readonly config = input<SsgoiConfig>({});
40
37
  readonly host = input<HostAnimation | undefined>(undefined);
38
+
39
+ private readonly el = inject(ElementRef<HTMLElement>);
40
+ private readonly platformId = inject(PLATFORM_ID);
41
+ private contextValue?: SsgoiContext;
42
+ private stopObserving?: () => void;
43
+
44
+ getContext(): SsgoiContext | undefined {
45
+ if (!isPlatformBrowser(this.platformId)) {
46
+ return undefined;
47
+ }
48
+
49
+ this.contextValue ??= createSggoiTransitionContext(this.config(), {
50
+ host: this.host(),
51
+ });
52
+ return this.contextValue;
53
+ }
54
+
55
+ ngAfterViewInit(): void {
56
+ const ssgoi = this.getContext();
57
+ if (!ssgoi) return;
58
+
59
+ this.stopObserving = observeSsgoiTransitions(this.el.nativeElement, ssgoi);
60
+ }
61
+
62
+ ngOnDestroy(): void {
63
+ this.stopObserving?.();
64
+ }
41
65
  }