@ssgoi/svelte 0.0.6 → 2.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 +260 -30
- package/dist/context.js +2 -2
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/index.js +1 -0
- package/dist/transition.d.ts +2 -2
- package/dist/transition.js +6 -6
- package/package.json +33 -7
package/README.md
CHANGED
|
@@ -1,58 +1,288 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ssgoi/svelte
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Svelte bindings for SSGOI - Native app-like page transitions for Svelte and SvelteKit.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
try this: [ssgoi.dev](https://ssgoi.dev)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+

|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## What is SSGOI?
|
|
10
|
+
|
|
11
|
+
SSGOI brings native app-like page transitions to the web. Transform your static page navigations into smooth, delightful experiences that users love.
|
|
12
|
+
|
|
13
|
+
### ✨ Key Features
|
|
14
|
+
|
|
15
|
+
- **🌍 Works Everywhere** - Unlike the browser's View Transition API, SSGOI works in all modern browsers (Chrome, Firefox, Safari)
|
|
16
|
+
- **🚀 SSR Ready** - Perfect compatibility with SvelteKit. No hydration issues, SEO-friendly
|
|
17
|
+
- **🎯 Use Your Router** - Keep your existing routing. SvelteKit's built-in router works seamlessly
|
|
18
|
+
- **💾 State Persistence** - Remembers animation state during navigation, even with browser back/forward
|
|
19
|
+
- **🧩 Svelte Native** - Built specifically for Svelte with actions and stores
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
10
22
|
|
|
11
23
|
```bash
|
|
12
|
-
|
|
13
|
-
|
|
24
|
+
npm install @ssgoi/svelte
|
|
25
|
+
# or
|
|
26
|
+
yarn add @ssgoi/svelte
|
|
27
|
+
# or
|
|
28
|
+
pnpm add @ssgoi/svelte
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
### 1. Wrap your app layout
|
|
34
|
+
|
|
35
|
+
```svelte
|
|
36
|
+
<!-- +layout.svelte -->
|
|
37
|
+
<script>
|
|
38
|
+
import { Ssgoi } from '@ssgoi/svelte';
|
|
39
|
+
import { fade } from '@ssgoi/svelte/view-transitions';
|
|
40
|
+
</script>
|
|
14
41
|
|
|
15
|
-
|
|
16
|
-
|
|
42
|
+
<Ssgoi config={{ defaultTransition: fade() }}>
|
|
43
|
+
<!-- ⚠️ Important: position: relative is required! -->
|
|
44
|
+
<div style="position: relative; min-height: 100vh;">
|
|
45
|
+
<slot />
|
|
46
|
+
</div>
|
|
47
|
+
</Ssgoi>
|
|
17
48
|
```
|
|
18
49
|
|
|
19
|
-
|
|
50
|
+
### 2. Wrap your pages
|
|
20
51
|
|
|
21
|
-
|
|
52
|
+
```svelte
|
|
53
|
+
<!-- +page.svelte -->
|
|
54
|
+
<script>
|
|
55
|
+
import { SsgoiTransition } from '@ssgoi/svelte';
|
|
56
|
+
import { page } from '$app/stores';
|
|
57
|
+
</script>
|
|
22
58
|
|
|
23
|
-
|
|
24
|
-
|
|
59
|
+
<SsgoiTransition id={$page.url.pathname}>
|
|
60
|
+
<h1>Welcome</h1>
|
|
61
|
+
<!-- Page content -->
|
|
62
|
+
</SsgoiTransition>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**That's it!** Your pages now transition smoothly with a fade effect.
|
|
66
|
+
|
|
67
|
+
## Advanced Transitions
|
|
68
|
+
|
|
69
|
+
### Route-based Transitions
|
|
70
|
+
|
|
71
|
+
Define different transitions for different routes:
|
|
72
|
+
|
|
73
|
+
```svelte
|
|
74
|
+
<script>
|
|
75
|
+
import { Ssgoi } from '@ssgoi/svelte';
|
|
76
|
+
import { slide, fade, scale, pinterest } from '@ssgoi/svelte/view-transitions';
|
|
25
77
|
|
|
26
|
-
|
|
27
|
-
|
|
78
|
+
const config = {
|
|
79
|
+
transitions: [
|
|
80
|
+
// Slide between tabs
|
|
81
|
+
{ from: '/home', to: '/about', transition: slide({ direction: 'left' }) },
|
|
82
|
+
{ from: '/about', to: '/home', transition: slide({ direction: 'right' }) },
|
|
83
|
+
|
|
84
|
+
// Scale up when entering details
|
|
85
|
+
{ from: '/products', to: '/products/*', transition: scale() },
|
|
86
|
+
|
|
87
|
+
// Pinterest-style image transitions
|
|
88
|
+
{ from: '/gallery', to: '/photo/*', transition: pinterest() }
|
|
89
|
+
],
|
|
90
|
+
defaultTransition: fade()
|
|
91
|
+
};
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<Ssgoi {config}>
|
|
95
|
+
<slot />
|
|
96
|
+
</Ssgoi>
|
|
28
97
|
```
|
|
29
98
|
|
|
30
|
-
|
|
99
|
+
### Symmetric Transitions
|
|
100
|
+
|
|
101
|
+
Automatically create bidirectional transitions:
|
|
31
102
|
|
|
32
|
-
|
|
103
|
+
```svelte
|
|
104
|
+
{
|
|
105
|
+
from: '/home',
|
|
106
|
+
to: '/about',
|
|
107
|
+
transition: slide({ direction: 'left' }),
|
|
108
|
+
symmetric: true // Automatically creates reverse transition
|
|
109
|
+
}
|
|
110
|
+
```
|
|
33
111
|
|
|
34
|
-
|
|
112
|
+
### Individual Element Animations
|
|
35
113
|
|
|
36
|
-
|
|
37
|
-
|
|
114
|
+
Animate specific elements during mount/unmount:
|
|
115
|
+
|
|
116
|
+
```svelte
|
|
117
|
+
<script>
|
|
118
|
+
import { transition } from '@ssgoi/svelte';
|
|
119
|
+
import { fadeIn, slideUp } from '@ssgoi/svelte/transitions';
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<div use:transition={{
|
|
123
|
+
key: 'card',
|
|
124
|
+
in: fadeIn(),
|
|
125
|
+
out: slideUp()
|
|
126
|
+
}}>
|
|
127
|
+
<h2>Animated Card</h2>
|
|
128
|
+
</div>
|
|
38
129
|
```
|
|
39
130
|
|
|
40
|
-
|
|
131
|
+
## SvelteKit App Example
|
|
41
132
|
|
|
42
|
-
```
|
|
43
|
-
|
|
133
|
+
```svelte
|
|
134
|
+
<!-- +layout.svelte -->
|
|
135
|
+
<script>
|
|
136
|
+
import { Ssgoi } from '@ssgoi/svelte';
|
|
137
|
+
import { slide } from '@ssgoi/svelte/view-transitions';
|
|
138
|
+
</script>
|
|
139
|
+
|
|
140
|
+
<Ssgoi config={{
|
|
141
|
+
defaultTransition: slide({ direction: 'left' })
|
|
142
|
+
}}>
|
|
143
|
+
<div style="position: relative; min-height: 100vh;">
|
|
144
|
+
<nav>
|
|
145
|
+
<a href="/">Home</a>
|
|
146
|
+
<a href="/about">About</a>
|
|
147
|
+
<a href="/products">Products</a>
|
|
148
|
+
</nav>
|
|
149
|
+
<slot />
|
|
150
|
+
</div>
|
|
151
|
+
</Ssgoi>
|
|
152
|
+
|
|
153
|
+
<!-- +page.svelte -->
|
|
154
|
+
<script>
|
|
155
|
+
import { SsgoiTransition } from '@ssgoi/svelte';
|
|
156
|
+
import { page } from '$app/stores';
|
|
157
|
+
</script>
|
|
158
|
+
|
|
159
|
+
<SsgoiTransition id={$page.url.pathname}>
|
|
160
|
+
<!-- Your page content -->
|
|
161
|
+
</SsgoiTransition>
|
|
44
162
|
```
|
|
45
163
|
|
|
46
|
-
|
|
164
|
+
## API Reference
|
|
47
165
|
|
|
48
|
-
|
|
166
|
+
### Components
|
|
49
167
|
|
|
50
|
-
|
|
168
|
+
#### `<Ssgoi>`
|
|
169
|
+
The provider component that manages transition context.
|
|
51
170
|
|
|
52
|
-
|
|
171
|
+
```svelte
|
|
172
|
+
<Ssgoi config={ssgoiConfig}>
|
|
173
|
+
<slot />
|
|
174
|
+
</Ssgoi>
|
|
175
|
+
```
|
|
53
176
|
|
|
54
|
-
|
|
177
|
+
#### `<SsgoiTransition>`
|
|
178
|
+
Wrapper component for pages that should transition.
|
|
55
179
|
|
|
56
|
-
```
|
|
57
|
-
|
|
180
|
+
```svelte
|
|
181
|
+
<SsgoiTransition id="/page-id">
|
|
182
|
+
<slot />
|
|
183
|
+
</SsgoiTransition>
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Actions
|
|
187
|
+
|
|
188
|
+
#### `use:transition`
|
|
189
|
+
Apply transitions to individual elements.
|
|
190
|
+
|
|
191
|
+
```svelte
|
|
192
|
+
<div use:transition={{
|
|
193
|
+
key: 'unique-key',
|
|
194
|
+
in: fadeIn(),
|
|
195
|
+
out: fadeOut()
|
|
196
|
+
}}>
|
|
197
|
+
Content
|
|
198
|
+
</div>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Stores
|
|
202
|
+
|
|
203
|
+
#### `transitioning`
|
|
204
|
+
Access transition state.
|
|
205
|
+
|
|
206
|
+
```svelte
|
|
207
|
+
<script>
|
|
208
|
+
import { transitioning } from '@ssgoi/svelte';
|
|
209
|
+
</script>
|
|
210
|
+
|
|
211
|
+
{#if $transitioning}
|
|
212
|
+
<p>Transitioning...</p>
|
|
213
|
+
{/if}
|
|
58
214
|
```
|
|
215
|
+
|
|
216
|
+
## Built-in Transitions
|
|
217
|
+
|
|
218
|
+
### Page Transitions (`@ssgoi/svelte/view-transitions`)
|
|
219
|
+
- `fade()` - Smooth opacity transition
|
|
220
|
+
- `slide()` - Directional sliding (left/right/up/down)
|
|
221
|
+
- `scale()` - Zoom in/out effect
|
|
222
|
+
- `hero()` - Shared element transitions
|
|
223
|
+
- `pinterest()` - Pinterest-style expand effect
|
|
224
|
+
- `ripple()` - Material Design ripple effect
|
|
225
|
+
|
|
226
|
+
### Element Transitions (`@ssgoi/svelte/transitions`)
|
|
227
|
+
- `fadeIn()` / `fadeOut()`
|
|
228
|
+
- `slideUp()` / `slideDown()` / `slideLeft()` / `slideRight()`
|
|
229
|
+
- `scaleIn()` / `scaleOut()`
|
|
230
|
+
- `bounce()`
|
|
231
|
+
- `blur()`
|
|
232
|
+
- `rotate()`
|
|
233
|
+
|
|
234
|
+
## Spring Physics Configuration
|
|
235
|
+
|
|
236
|
+
All transitions use spring physics for natural motion:
|
|
237
|
+
|
|
238
|
+
```javascript
|
|
239
|
+
slide({
|
|
240
|
+
direction: 'left',
|
|
241
|
+
spring: {
|
|
242
|
+
stiffness: 300, // 1-1000, higher = faster
|
|
243
|
+
damping: 30 // 0-100, higher = less oscillation
|
|
244
|
+
}
|
|
245
|
+
})
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## TypeScript Support
|
|
249
|
+
|
|
250
|
+
SSGOI is written in TypeScript and provides full type definitions:
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
import type { SsgoiConfig, TransitionConfig } from '@ssgoi/svelte';
|
|
254
|
+
|
|
255
|
+
const config: SsgoiConfig = {
|
|
256
|
+
// Full type safety
|
|
257
|
+
};
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Browser Support
|
|
261
|
+
|
|
262
|
+
- Chrome/Edge 88+
|
|
263
|
+
- Firefox 78+
|
|
264
|
+
- Safari 14+
|
|
265
|
+
- All modern mobile browsers
|
|
266
|
+
|
|
267
|
+
## Performance
|
|
268
|
+
|
|
269
|
+
- Minimal bundle size (~8kb gzipped)
|
|
270
|
+
- Hardware-accelerated animations
|
|
271
|
+
- Automatic cleanup and memory management
|
|
272
|
+
- Smart preloading for instant transitions
|
|
273
|
+
|
|
274
|
+
## Documentation
|
|
275
|
+
|
|
276
|
+
Visit [https://ssgoi.dev](https://ssgoi.dev) for:
|
|
277
|
+
- Complete API reference
|
|
278
|
+
- Interactive examples
|
|
279
|
+
- Advanced patterns
|
|
280
|
+
- Migration guides
|
|
281
|
+
|
|
282
|
+
## Contributing
|
|
283
|
+
|
|
284
|
+
We welcome contributions! Please see our [contributing guide](https://github.com/meursyphus/ssgoi/blob/main/CONTRIBUTING.md) for details.
|
|
285
|
+
|
|
286
|
+
## License
|
|
287
|
+
|
|
288
|
+
MIT © [MeurSyphus](https://github.com/meursyphus)
|
package/dist/context.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getContext, setContext } from 'svelte';
|
|
2
|
-
|
|
2
|
+
var SSGOI_CONTEXT_KEY = Symbol('ssgoi');
|
|
3
3
|
export function setSsgoiContext(context) {
|
|
4
4
|
setContext(SSGOI_CONTEXT_KEY, context);
|
|
5
5
|
}
|
|
6
6
|
export function getSsgoiContext() {
|
|
7
|
-
|
|
7
|
+
var context = getContext(SSGOI_CONTEXT_KEY);
|
|
8
8
|
if (!context) {
|
|
9
9
|
throw new Error('getSsgoiContext must be called within Ssgoi component');
|
|
10
10
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@ssgoi/core/presets";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@ssgoi/core/presets";
|
package/dist/transition.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Transition, type TransitionKey } from "@ssgoi/core";
|
|
2
|
-
export declare const transition: (node: HTMLElement, params: Transition & {
|
|
2
|
+
export declare const transition: <TAnimationValue = number>(node: HTMLElement, params: Transition<undefined, TAnimationValue> & {
|
|
3
3
|
key: TransitionKey;
|
|
4
4
|
}) => {
|
|
5
|
-
update(newParams: Transition & {
|
|
5
|
+
update(newParams: Transition<undefined, TAnimationValue> & {
|
|
6
6
|
key: TransitionKey;
|
|
7
7
|
}): void;
|
|
8
8
|
destroy(): void;
|
package/dist/transition.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { transition as _transition, } from "@ssgoi/core";
|
|
2
|
-
export
|
|
3
|
-
|
|
2
|
+
export var transition = function (node, params) {
|
|
3
|
+
var callback = _transition({
|
|
4
4
|
key: params.key,
|
|
5
5
|
in: params.in,
|
|
6
6
|
out: params.out,
|
|
7
7
|
});
|
|
8
|
-
|
|
8
|
+
var cleanup = callback(node);
|
|
9
9
|
return {
|
|
10
|
-
update(newParams) {
|
|
10
|
+
update: function (newParams) {
|
|
11
11
|
callback = _transition({
|
|
12
12
|
key: newParams.key,
|
|
13
13
|
in: newParams.in,
|
|
@@ -15,8 +15,8 @@ export const transition = (node, params) => {
|
|
|
15
15
|
});
|
|
16
16
|
cleanup = callback(node);
|
|
17
17
|
},
|
|
18
|
-
destroy() {
|
|
19
|
-
cleanup
|
|
18
|
+
destroy: function () {
|
|
19
|
+
cleanup === null || cleanup === void 0 ? void 0 : cleanup();
|
|
20
20
|
},
|
|
21
21
|
};
|
|
22
22
|
};
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ssgoi/svelte",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Svelte bindings for SSGOI - Native app-like page transitions for Svelte and SvelteKit applications",
|
|
5
|
+
"private": false,
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
4
8
|
"files": [
|
|
5
9
|
"dist",
|
|
6
10
|
"!dist/**/*.test.*",
|
|
7
11
|
"!dist/**/*.spec.*"
|
|
8
12
|
],
|
|
9
|
-
"sideEffects": [
|
|
10
|
-
"**/*.css"
|
|
11
|
-
],
|
|
12
13
|
"svelte": "./dist/index.js",
|
|
13
14
|
"types": "./dist/index.d.ts",
|
|
14
15
|
"type": "module",
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"@ssgoi/core": "0.0
|
|
17
|
+
"@ssgoi/core": "2.0.0"
|
|
17
18
|
},
|
|
18
19
|
"peerDependencies": {
|
|
19
20
|
"svelte": "^5.0.0"
|
|
@@ -39,8 +40,29 @@
|
|
|
39
40
|
"vite": "^6.2.6"
|
|
40
41
|
},
|
|
41
42
|
"keywords": [
|
|
42
|
-
"svelte"
|
|
43
|
+
"svelte",
|
|
44
|
+
"page-transition",
|
|
45
|
+
"animation",
|
|
46
|
+
"ssgoi",
|
|
47
|
+
"spring-physics"
|
|
43
48
|
],
|
|
49
|
+
"author": "MeurSyphus <tmdeoans@snu.ac.kr>",
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/meursyphus/ssgoi.git",
|
|
54
|
+
"directory": "packages/svelte"
|
|
55
|
+
},
|
|
56
|
+
"homepage": "https://ssgoi.dev",
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/meursyphus/ssgoi/issues"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
},
|
|
63
|
+
"engines": {
|
|
64
|
+
"node": ">=18.0.0"
|
|
65
|
+
},
|
|
44
66
|
"exports": {
|
|
45
67
|
".": {
|
|
46
68
|
"types": "./dist/index.d.ts",
|
|
@@ -57,10 +79,14 @@
|
|
|
57
79
|
"./types": {
|
|
58
80
|
"types": "./dist/types.d.ts",
|
|
59
81
|
"import": "./dist/types.js"
|
|
82
|
+
},
|
|
83
|
+
"./presets": {
|
|
84
|
+
"types": "./dist/presets/index.d.ts",
|
|
85
|
+
"import": "./dist/presets/index.js"
|
|
60
86
|
}
|
|
61
87
|
},
|
|
62
88
|
"scripts": {
|
|
63
|
-
"
|
|
89
|
+
"dev": "svelte-package --watch",
|
|
64
90
|
"build": "svelte-package",
|
|
65
91
|
"format": "prettier --write .",
|
|
66
92
|
"lint": "prettier --check . && eslint ."
|