@ssgoi/svelte 3.0.0 → 4.0.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
@@ -129,14 +129,14 @@ Animate specific elements during mount/unmount:
129
129
  ```svelte
130
130
  <script>
131
131
  import { transition } from "@ssgoi/svelte";
132
- import { fadeIn, slideUp } from "@ssgoi/svelte/transitions";
132
+ import { fade, slide } from "@ssgoi/svelte/transitions";
133
133
  </script>
134
134
 
135
135
  <div
136
136
  use:transition={{
137
137
  key: "card",
138
- in: fadeIn(),
139
- out: slideUp(),
138
+ in: fade(),
139
+ out: slide({ direction: 'up' }),
140
140
  }}
141
141
  >
142
142
  <h2>Animated Card</h2>
@@ -210,8 +210,8 @@ Apply transitions to individual elements.
210
210
  <div
211
211
  use:transition={{
212
212
  key: "unique-key",
213
- in: fadeIn(),
214
- out: fadeOut(),
213
+ in: fade(),
214
+ out: fade(),
215
215
  }}
216
216
  >
217
217
  Content
@@ -246,9 +246,9 @@ Access transition state.
246
246
 
247
247
  ### Element Transitions (`@ssgoi/svelte/transitions`)
248
248
 
249
- - `fadeIn()` / `fadeOut()`
250
- - `slideUp()` / `slideDown()` / `slideLeft()` / `slideRight()`
251
- - `scaleIn()` / `scaleOut()`
249
+ - `fade()`
250
+ - `slide({ direction: 'up' | 'down' | 'left' | 'right' })`
251
+ - `scale()`
252
252
  - `bounce()`
253
253
  - `blur()`
254
254
  - `rotate()`
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { transition } from "./transition.js";
2
2
  export { default as Ssgoi } from "./ssgoi.svelte";
3
3
  export { default as SsgoiTransition } from "./ssgoi-transition.svelte";
4
+ export { default as TransitionScope } from "./transition-scope.svelte";
4
5
  export * from "./types.js";
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export { transition } from "./transition.js";
2
2
  export { default as Ssgoi } from "./ssgoi.svelte";
3
3
  export { default as SsgoiTransition } from "./ssgoi-transition.svelte";
4
+ export { default as TransitionScope } from "./transition-scope.svelte";
4
5
  export * from "./types.js";
@@ -0,0 +1,30 @@
1
+ <script lang="ts">
2
+ import { createTransitionScope } from "@ssgoi/core";
3
+
4
+ interface Props {
5
+ children: () => any;
6
+ }
7
+
8
+ let { children }: Props = $props();
9
+ </script>
10
+
11
+ <!--
12
+ TransitionScope creates a boundary for local-scoped transitions.
13
+
14
+ Child elements with `scope: 'local'` will:
15
+ - Skip IN animation when mounted simultaneously with the scope
16
+ - Skip OUT animation when unmounted simultaneously with the scope
17
+
18
+ @example
19
+ ```svelte
20
+ <TransitionScope>
21
+ <div use:transition={[fadeIn(), { scope: 'local' }]}>
22
+ This will only animate when added/removed independently,
23
+ not when the entire scope mounts/unmounts.
24
+ </div>
25
+ </TransitionScope>
26
+ ```
27
+ -->
28
+ <div use:createTransitionScope style="display: contents;">
29
+ {@render children()}
30
+ </div>
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ children: () => any;
3
+ }
4
+ declare const TransitionScope: import("svelte").Component<Props, {}, "">;
5
+ type TransitionScope = ReturnType<typeof TransitionScope>;
6
+ export default TransitionScope;
@@ -1,9 +1,17 @@
1
- import { type Transition, type TransitionKey } from "@ssgoi/core";
2
- export declare const transition: <TAnimationValue = number>(node: HTMLElement, params: Transition<undefined, TAnimationValue> & {
3
- key?: TransitionKey;
4
- }) => {
5
- update(newParams: Transition<undefined, TAnimationValue> & {
6
- key?: TransitionKey;
7
- }): void;
1
+ import { type Transition, type TransitionKey, type TransitionScope } from "@ssgoi/core";
2
+ type TransitionParams = Transition<undefined> & {
3
+ key: TransitionKey;
4
+ scope?: TransitionScope;
5
+ };
6
+ /**
7
+ * Svelte action for element transitions
8
+ *
9
+ * Uses Svelte's destroy callback for OUT transition detection.
10
+ * This ensures the correct transition config is used even when
11
+ * params are updated (e.g., during SvelteKit page navigation).
12
+ */
13
+ export declare const transition: (node: HTMLElement, params: TransitionParams) => {
14
+ update(newParams: TransitionParams): void;
8
15
  destroy(): void;
9
16
  };
17
+ export {};
@@ -1,23 +1,32 @@
1
1
  import { transition as _transition, } from "@ssgoi/core";
2
+ /**
3
+ * Svelte action for element transitions
4
+ *
5
+ * Uses Svelte's destroy callback for OUT transition detection.
6
+ * This ensures the correct transition config is used even when
7
+ * params are updated (e.g., during SvelteKit page navigation).
8
+ */
2
9
  export var transition = function (node, params) {
3
10
  var callback = _transition({
4
- key: params === null || params === void 0 ? void 0 : params.key,
5
- in: params === null || params === void 0 ? void 0 : params.in,
6
- out: params === null || params === void 0 ? void 0 : params.out,
7
- ref: node,
11
+ key: params.key,
12
+ in: params.in,
13
+ out: params.out,
14
+ scope: params.scope,
8
15
  });
9
16
  var cleanup = callback(node);
10
17
  return {
11
18
  update: function (newParams) {
12
19
  callback = _transition({
13
- key: newParams === null || newParams === void 0 ? void 0 : newParams.key,
14
- in: newParams === null || newParams === void 0 ? void 0 : newParams.in,
15
- out: newParams === null || newParams === void 0 ? void 0 : newParams.out,
16
- ref: node,
20
+ key: newParams.key,
21
+ in: newParams.in,
22
+ out: newParams.out,
23
+ scope: newParams.scope,
17
24
  });
18
25
  cleanup = callback(node);
19
26
  },
20
27
  destroy: function () {
28
+ // Call cleanup to trigger OUT transition with the correct config
29
+ // The cleanup function captures the transition config at registration time
21
30
  cleanup === null || cleanup === void 0 ? void 0 : cleanup();
22
31
  },
23
32
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssgoi/svelte",
3
- "version": "3.0.0",
3
+ "version": "4.0.0",
4
4
  "description": "Svelte bindings for SSGOI - Native app-like page transitions for Svelte and SvelteKit applications",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",
@@ -14,7 +14,7 @@
14
14
  "types": "./dist/index.d.ts",
15
15
  "type": "module",
16
16
  "dependencies": {
17
- "@ssgoi/core": "^3.0.0"
17
+ "@ssgoi/core": "^4.0.0"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "svelte": "^5.0.0"