@ssgoi/angular 3.0.0 → 5.2.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
@@ -77,7 +77,7 @@ The value you pass to `[ssgoiTransition]` should uniquely identify the view (com
77
77
  ```typescript
78
78
  import { Component } from "@angular/core";
79
79
  import { TransitionDirective } from "@ssgoi/angular";
80
- import { fadeIn, fadeOut } from "@ssgoi/angular/transitions";
80
+ import { fade } from "@ssgoi/angular/transitions";
81
81
 
82
82
  @Component({
83
83
  selector: "app-call-to-action",
@@ -87,8 +87,8 @@ import { fadeIn, fadeOut } from "@ssgoi/angular/transitions";
87
87
  <button
88
88
  [transition]="{
89
89
  key: 'cta',
90
- in: fadeIn({ duration: 220 }),
91
- out: fadeOut({ duration: 180 })
90
+ in: fade({ duration: 220 }),
91
+ out: fade({ duration: 180 })
92
92
  }"
93
93
  >
94
94
  Get Started
@@ -128,14 +128,9 @@ Element-level factories:
128
128
 
129
129
  ```typescript
130
130
  import {
131
- fadeIn,
132
- fadeOut,
133
- slideUp,
134
- slideDown,
135
- slideLeft,
136
- slideRight,
137
- scaleIn,
138
- scaleOut,
131
+ fade,
132
+ slide,
133
+ scale,
139
134
  bounce,
140
135
  blur,
141
136
  rotate,
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ssgoi/angular",
3
- "version": "3.0.0",
3
+ "version": "5.2.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": "3.0.0"
9
+ "@ssgoi/core": "^5.2.0"
10
10
  },
11
11
  "peerDependencies": {
12
12
  "@angular/common": "^20.0.0",
package/src/lib/index.ts CHANGED
@@ -4,6 +4,7 @@ export {
4
4
  TransitionDirective,
5
5
  TransitionDirectiveConfig,
6
6
  } from "./transition.directive";
7
+ export { TransitionScopeDirective } from "./transition-scope.directive";
7
8
  export { injectSsgoi, SSGOI_CONTEXT } from "./context";
8
9
  export { transition } from "@ssgoi/core";
9
10
  export * from "./types";
@@ -0,0 +1,54 @@
1
+ import {
2
+ Directive,
3
+ ElementRef,
4
+ OnInit,
5
+ OnDestroy,
6
+ inject,
7
+ PLATFORM_ID,
8
+ } from "@angular/core";
9
+ import { isPlatformBrowser } from "@angular/common";
10
+ import { createTransitionScope } from "@ssgoi/core";
11
+
12
+ /**
13
+ * TransitionScope creates a boundary for local-scoped transitions.
14
+ *
15
+ * Child elements with `scope: 'local'` will:
16
+ * - Skip IN animation when mounted simultaneously with the scope
17
+ * - Skip OUT animation when unmounted simultaneously with the scope
18
+ *
19
+ * @example
20
+ * ```html
21
+ * <div transitionScope>
22
+ * <div [transition]="{ scope: 'local', in: ..., out: ... }">
23
+ * Content
24
+ * </div>
25
+ * </div>
26
+ * ```
27
+ */
28
+ @Directive({
29
+ selector: "[transitionScope]",
30
+ host: {
31
+ style: "display: contents",
32
+ },
33
+ })
34
+ export class TransitionScopeDirective implements OnInit, OnDestroy {
35
+ private readonly el = inject(ElementRef<HTMLElement>);
36
+ private readonly platformId = inject(PLATFORM_ID);
37
+ private cleanup?: () => void;
38
+
39
+ ngOnInit(): void {
40
+ if (!isPlatformBrowser(this.platformId)) {
41
+ return;
42
+ }
43
+
44
+ const cleanupResult = createTransitionScope()(this.el.nativeElement);
45
+
46
+ if (cleanupResult) {
47
+ this.cleanup = cleanupResult;
48
+ }
49
+ }
50
+
51
+ ngOnDestroy(): void {
52
+ this.cleanup?.();
53
+ }
54
+ }
@@ -12,10 +12,12 @@ import { transition as coreTransition } from "@ssgoi/core";
12
12
  import type {
13
13
  Transition as CoreTransitionConfig,
14
14
  TransitionKey as CoreTransitionKey,
15
+ TransitionScope as CoreTransitionScope,
15
16
  } from "@ssgoi/core";
16
17
 
17
18
  export type TransitionDirectiveConfig = CoreTransitionConfig & {
18
19
  key?: CoreTransitionKey;
20
+ scope?: CoreTransitionScope;
19
21
  };
20
22
 
21
23
  @Directive({
@@ -38,7 +40,7 @@ export class TransitionDirective implements OnInit, OnDestroy {
38
40
  key: config.key,
39
41
  in: config.in,
40
42
  out: config.out,
41
- ref: this.el.nativeElement,
43
+ scope: config.scope,
42
44
  })(this.el.nativeElement);
43
45
 
44
46
  if (cleanupResult) {