@castlenine/svelte-aoe 1.1.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/LICENSE +21 -0
- package/README.md +133 -0
- package/dist/animations.css +370 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.svelte +35 -0
- package/dist/index.svelte.d.ts +30 -0
- package/dist/index.svelte.d.ts.map +1 -0
- package/package.json +98 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Alexandre "Castlenine"
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# `@castlenine/svelte-aoe`
|
|
4
|
+
|
|
5
|
+
[![npm.badge]][npm] [![download.badge]][download]
|
|
6
|
+
|
|
7
|
+
A Svelte component to animate elements, without dependencies
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
`@castlenine/svelte-aoe` utilizes the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) to detect when an element enters the viewport.
|
|
11
|
+
|
|
12
|
+
When the element is detected as being in the viewport, `@castlenine/svelte-aoe` applies a class that triggers a CSS animation.
|
|
13
|
+
|
|
14
|
+
## 🚀 [Demo](https://casltenine-svelte-aoe.vercel.app/)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Use your package manager to install:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm i @castlenine/svelte-aoe --save-dev
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Setup
|
|
25
|
+
|
|
26
|
+
- Import the package
|
|
27
|
+
|
|
28
|
+
```svelte
|
|
29
|
+
import AnimateOnEnter from '@castlenine/svelte-aoe';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- Add the component to your layout/page/component.
|
|
33
|
+
|
|
34
|
+
```svelte
|
|
35
|
+
<AnimateOnEnter />
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
- Add a `data-aoe` attribute to the element that you want to animate and define an animation.
|
|
39
|
+
|
|
40
|
+
```svelte
|
|
41
|
+
<img data-aoe="fade-up" src="https://dummyimage.com/500x300"/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Example: SvelteKit Global Setup
|
|
45
|
+
|
|
46
|
+
File: `src/routes/+layout.svelte`
|
|
47
|
+
|
|
48
|
+
```svelte
|
|
49
|
+
<script>
|
|
50
|
+
import AnimateOnEnter from '@castlenine/svelte-aoe';
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<AnimateOnEnter />
|
|
54
|
+
|
|
55
|
+
<slot />
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Animations
|
|
59
|
+
|
|
60
|
+
### Normal speed
|
|
61
|
+
|
|
62
|
+
- `up`
|
|
63
|
+
- `right`
|
|
64
|
+
- `left`
|
|
65
|
+
- `down`
|
|
66
|
+
- `fade`
|
|
67
|
+
- `fade-up`
|
|
68
|
+
- `fade-right`
|
|
69
|
+
- `fade-left`
|
|
70
|
+
- `fade-down`
|
|
71
|
+
|
|
72
|
+
### Fast speed
|
|
73
|
+
|
|
74
|
+
- `up-fast`
|
|
75
|
+
- `right-fast`
|
|
76
|
+
- `left-fast`
|
|
77
|
+
- `down-fast`
|
|
78
|
+
- `fade-fast`
|
|
79
|
+
- `fade-up-fast`
|
|
80
|
+
- `fade-right-fast`
|
|
81
|
+
- `fade-left-fast`
|
|
82
|
+
- `fade-down-fast`
|
|
83
|
+
|
|
84
|
+
### Slow speed
|
|
85
|
+
|
|
86
|
+
- `up-slow`
|
|
87
|
+
- `right-slow`
|
|
88
|
+
- `left-slow`
|
|
89
|
+
- `down-slow`
|
|
90
|
+
- `fade-slow`
|
|
91
|
+
- `fade-up-slow`
|
|
92
|
+
- `fade-right-slow`
|
|
93
|
+
- `fade-left-slow`
|
|
94
|
+
- `fade-down-slow`
|
|
95
|
+
|
|
96
|
+
You can add your own animations by following the same pattern in your CSS.
|
|
97
|
+
|
|
98
|
+
```css
|
|
99
|
+
[data-aoe='your-animation'] {
|
|
100
|
+
transform: translateX(-45px);
|
|
101
|
+
transition:
|
|
102
|
+
transform 600ms,
|
|
103
|
+
opacity 900ms;
|
|
104
|
+
|
|
105
|
+
&.aoe {
|
|
106
|
+
transform: translateX(0);
|
|
107
|
+
transition-delay: 0s;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Properties
|
|
113
|
+
|
|
114
|
+
| Property name | Type | Default value |
|
|
115
|
+
| ------------- | -------------------------------------------- | ------------- |
|
|
116
|
+
| `root` | `Document`, `Element`, `null`, `undefined` | `null` |
|
|
117
|
+
| `rootMargin` | `string` in pixel (`px`) or percentage (`%`) | `0px` |
|
|
118
|
+
| `threshold` | `number`, `number[]` between `0` and `1.0` | `0.3` |
|
|
119
|
+
|
|
120
|
+
`root` is the element that is used as the viewport for checking visibility of the target. Must be the ancestor of the target. Defaults to the browser viewport if not specified or if `null`. Defaults to `null` (browser viewport).
|
|
121
|
+
|
|
122
|
+
`rootMargin` is the margin around the root. Can have values similar to the CSS margin property, e.g. `"10px 20px 30px 40px"` (top, right, bottom, left). The values can be percentages. Defaults to `'0px'` (no margin).
|
|
123
|
+
|
|
124
|
+
`threshold` is either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed. A value of `0.0` or `0` indicates that even a single pixel of the target is visible. A value of `1.0` or `1` indicates that the target is completely visible. Defaults to `0.3` (30%).
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
Inspired by [Animate on Scroll](https://michalsnik.github.io/aos/) and [lliamscholtz/svelte-aoe](https://github.com/lliamscholtz/svelte-aoe)
|
|
129
|
+
|
|
130
|
+
[npm]: https://www.npmjs.com/package/@castlenine/svelte-aoe
|
|
131
|
+
[npm.badge]: https://img.shields.io/npm/v/@castlenine/svelte-aoe
|
|
132
|
+
[download]: https://www.npmjs.com/package/@castlenine/svelte-aoe
|
|
133
|
+
[download.badge]: https://img.shields.io/npm/d18m/@castlenine/svelte-aoe
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
/* **************************************************** */
|
|
2
|
+
/* [direction] */
|
|
3
|
+
|
|
4
|
+
/* normal speed */
|
|
5
|
+
[data-aoe='up'] {
|
|
6
|
+
transform: translateY(45px);
|
|
7
|
+
transition:
|
|
8
|
+
transform 600ms,
|
|
9
|
+
opacity 900ms;
|
|
10
|
+
|
|
11
|
+
&.aoe {
|
|
12
|
+
transform: translateY(0);
|
|
13
|
+
transition-delay: 0s;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
[data-aoe='right'] {
|
|
18
|
+
transform: translateX(-45px);
|
|
19
|
+
transition:
|
|
20
|
+
transform 600ms,
|
|
21
|
+
opacity 900ms;
|
|
22
|
+
|
|
23
|
+
&.aoe {
|
|
24
|
+
transform: translateX(0);
|
|
25
|
+
transition-delay: 0s;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
[data-aoe='down'] {
|
|
30
|
+
transform: translateY(-45px);
|
|
31
|
+
transition:
|
|
32
|
+
transform 600ms,
|
|
33
|
+
opacity 900ms;
|
|
34
|
+
|
|
35
|
+
&.aoe {
|
|
36
|
+
transform: translateY(0);
|
|
37
|
+
transition-delay: 0s;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[data-aoe='left'] {
|
|
42
|
+
transform: translateX(45px);
|
|
43
|
+
transition:
|
|
44
|
+
transform 600ms,
|
|
45
|
+
opacity 900ms;
|
|
46
|
+
|
|
47
|
+
&.aoe {
|
|
48
|
+
opacity: 1;
|
|
49
|
+
transform: translateX(0);
|
|
50
|
+
transition-delay: 0s;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* fast speed */
|
|
55
|
+
[data-aoe='up-fast'] {
|
|
56
|
+
transform: translateY(45px);
|
|
57
|
+
transition:
|
|
58
|
+
transform 370ms,
|
|
59
|
+
opacity 555ms;
|
|
60
|
+
|
|
61
|
+
&.aoe {
|
|
62
|
+
transform: translateY(0);
|
|
63
|
+
transition-delay: 0s;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[data-aoe='right-fast'] {
|
|
68
|
+
transform: translateX(-45px);
|
|
69
|
+
transition:
|
|
70
|
+
transform 370ms,
|
|
71
|
+
opacity 555ms;
|
|
72
|
+
|
|
73
|
+
&.aoe {
|
|
74
|
+
transform: translateX(0);
|
|
75
|
+
transition-delay: 0s;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[data-aoe='down-fast'] {
|
|
80
|
+
transform: translateY(-45px);
|
|
81
|
+
transition:
|
|
82
|
+
transform 370ms,
|
|
83
|
+
opacity 555ms;
|
|
84
|
+
|
|
85
|
+
&.aoe {
|
|
86
|
+
transform: translateY(0);
|
|
87
|
+
transition-delay: 0s;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
[data-aoe='left-fast'] {
|
|
92
|
+
transform: translateX(45px);
|
|
93
|
+
transition:
|
|
94
|
+
transform 370ms,
|
|
95
|
+
opacity 555ms;
|
|
96
|
+
|
|
97
|
+
&.aoe {
|
|
98
|
+
opacity: 1;
|
|
99
|
+
transform: translateX(0);
|
|
100
|
+
transition-delay: 0s;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* slow speed */
|
|
105
|
+
[data-aoe='up-slow'] {
|
|
106
|
+
transform: translateY(45px);
|
|
107
|
+
transition:
|
|
108
|
+
transform 975ms,
|
|
109
|
+
opacity 1500ms;
|
|
110
|
+
|
|
111
|
+
&.aoe {
|
|
112
|
+
transform: translateY(0);
|
|
113
|
+
transition-delay: 0s;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
[data-aoe='right-slow'] {
|
|
118
|
+
transform: translateX(-45px);
|
|
119
|
+
transition:
|
|
120
|
+
transform 975ms,
|
|
121
|
+
opacity 1500ms;
|
|
122
|
+
|
|
123
|
+
&.aoe {
|
|
124
|
+
transform: translateX(0);
|
|
125
|
+
transition-delay: 0s;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
[data-aoe='down-slow'] {
|
|
130
|
+
transform: translateY(-45px);
|
|
131
|
+
transition:
|
|
132
|
+
transform 975ms,
|
|
133
|
+
opacity 1500ms;
|
|
134
|
+
|
|
135
|
+
&.aoe {
|
|
136
|
+
transform: translateY(0);
|
|
137
|
+
transition-delay: 0s;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
[data-aoe='left-slow'] {
|
|
142
|
+
transform: translateX(45px);
|
|
143
|
+
transition:
|
|
144
|
+
transform 975ms,
|
|
145
|
+
opacity 1500ms;
|
|
146
|
+
|
|
147
|
+
&.aoe {
|
|
148
|
+
opacity: 1;
|
|
149
|
+
transform: translateX(0);
|
|
150
|
+
transition-delay: 0s;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* **************************************************** */
|
|
155
|
+
/* fade-[direction] */
|
|
156
|
+
|
|
157
|
+
/* normal speed */
|
|
158
|
+
[data-aoe='fade'] {
|
|
159
|
+
opacity: 0;
|
|
160
|
+
transition: opacity 900ms;
|
|
161
|
+
|
|
162
|
+
&.aoe {
|
|
163
|
+
opacity: 1;
|
|
164
|
+
transition-delay: 0s;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
[data-aoe='fade-up'] {
|
|
169
|
+
opacity: 0;
|
|
170
|
+
transform: translateY(45px);
|
|
171
|
+
transition:
|
|
172
|
+
transform 600ms,
|
|
173
|
+
opacity 900ms;
|
|
174
|
+
|
|
175
|
+
&.aoe {
|
|
176
|
+
opacity: 1;
|
|
177
|
+
transform: translateY(0);
|
|
178
|
+
transition-delay: 0s;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
[data-aoe='fade-right'] {
|
|
183
|
+
opacity: 0;
|
|
184
|
+
transform: translateX(-45px);
|
|
185
|
+
transition:
|
|
186
|
+
transform 600ms,
|
|
187
|
+
opacity 900ms;
|
|
188
|
+
|
|
189
|
+
&.aoe {
|
|
190
|
+
opacity: 1;
|
|
191
|
+
transform: translateX(0);
|
|
192
|
+
transition-delay: 0s;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
[data-aoe='fade-down'] {
|
|
197
|
+
opacity: 0;
|
|
198
|
+
transform: translateY(-45px);
|
|
199
|
+
transition:
|
|
200
|
+
transform 600ms,
|
|
201
|
+
opacity 900ms;
|
|
202
|
+
|
|
203
|
+
&.aoe {
|
|
204
|
+
opacity: 1;
|
|
205
|
+
transform: translateY(0);
|
|
206
|
+
transition-delay: 0s;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
[data-aoe='fade-left'] {
|
|
211
|
+
opacity: 0;
|
|
212
|
+
transform: translateX(45px);
|
|
213
|
+
transition:
|
|
214
|
+
transform 600ms,
|
|
215
|
+
opacity 900ms;
|
|
216
|
+
|
|
217
|
+
&.aoe {
|
|
218
|
+
opacity: 1;
|
|
219
|
+
transform: translateX(0);
|
|
220
|
+
transition-delay: 0s;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/* fast speed */
|
|
225
|
+
[data-aoe='fade-fast'] {
|
|
226
|
+
opacity: 0;
|
|
227
|
+
transition: opacity 555ms;
|
|
228
|
+
|
|
229
|
+
&.aoe {
|
|
230
|
+
opacity: 1;
|
|
231
|
+
transition-delay: 0s;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
[data-aoe='fade-up-fast'] {
|
|
236
|
+
opacity: 0;
|
|
237
|
+
transform: translateY(45px);
|
|
238
|
+
transition:
|
|
239
|
+
transform 370ms,
|
|
240
|
+
opacity 555ms;
|
|
241
|
+
|
|
242
|
+
&.aoe {
|
|
243
|
+
opacity: 1;
|
|
244
|
+
transform: translateY(0);
|
|
245
|
+
transition-delay: 0s;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
[data-aoe='fade-right-fast'] {
|
|
250
|
+
opacity: 0;
|
|
251
|
+
transform: translateX(-45px);
|
|
252
|
+
transition:
|
|
253
|
+
transform 370ms,
|
|
254
|
+
opacity 555ms;
|
|
255
|
+
|
|
256
|
+
&.aoe {
|
|
257
|
+
opacity: 1;
|
|
258
|
+
transform: translateX(0);
|
|
259
|
+
transition-delay: 0s;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
[data-aoe='fade-down-fast'] {
|
|
264
|
+
opacity: 0;
|
|
265
|
+
transform: translateY(-45px);
|
|
266
|
+
transition:
|
|
267
|
+
transform 370ms,
|
|
268
|
+
opacity 555ms;
|
|
269
|
+
|
|
270
|
+
&.aoe {
|
|
271
|
+
opacity: 1;
|
|
272
|
+
transform: translateY(0);
|
|
273
|
+
transition-delay: 0s;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
[data-aoe='fade-left-fast'] {
|
|
278
|
+
opacity: 0;
|
|
279
|
+
transform: translateX(45px);
|
|
280
|
+
transition:
|
|
281
|
+
transform 370ms,
|
|
282
|
+
opacity 555ms;
|
|
283
|
+
|
|
284
|
+
&.aoe {
|
|
285
|
+
opacity: 1;
|
|
286
|
+
transform: translateX(0);
|
|
287
|
+
transition-delay: 0s;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/* slow speed */
|
|
292
|
+
[data-aoe='fade-slow'] {
|
|
293
|
+
opacity: 0;
|
|
294
|
+
transition: opacity 1500ms;
|
|
295
|
+
|
|
296
|
+
&.aoe {
|
|
297
|
+
opacity: 1;
|
|
298
|
+
transition-delay: 0s;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
[data-aoe='fade-up-slow'] {
|
|
303
|
+
opacity: 0;
|
|
304
|
+
transform: translateY(45px);
|
|
305
|
+
transition:
|
|
306
|
+
transform 975ms,
|
|
307
|
+
opacity 1500ms;
|
|
308
|
+
|
|
309
|
+
&.aoe {
|
|
310
|
+
opacity: 1;
|
|
311
|
+
transform: translateY(0);
|
|
312
|
+
transition-delay: 0s;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
[data-aoe='fade-right-slow'] {
|
|
317
|
+
opacity: 0;
|
|
318
|
+
transform: translateX(-45px);
|
|
319
|
+
transition:
|
|
320
|
+
transform 975ms,
|
|
321
|
+
opacity 1500ms;
|
|
322
|
+
|
|
323
|
+
&.aoe {
|
|
324
|
+
opacity: 1;
|
|
325
|
+
transform: translateX(0);
|
|
326
|
+
transition-delay: 0s;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
[data-aoe='fade-down-slow'] {
|
|
331
|
+
opacity: 0;
|
|
332
|
+
transform: translateY(-45px);
|
|
333
|
+
transition:
|
|
334
|
+
transform 975ms,
|
|
335
|
+
opacity 1500ms;
|
|
336
|
+
|
|
337
|
+
&.aoe {
|
|
338
|
+
opacity: 1;
|
|
339
|
+
transform: translateY(0);
|
|
340
|
+
transition-delay: 0s;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
[data-aoe='fade-left-slow'] {
|
|
345
|
+
opacity: 0;
|
|
346
|
+
transform: translateX(45px);
|
|
347
|
+
transition:
|
|
348
|
+
transform 975ms,
|
|
349
|
+
opacity 1500ms;
|
|
350
|
+
|
|
351
|
+
&.aoe {
|
|
352
|
+
opacity: 1;
|
|
353
|
+
transform: translateX(0);
|
|
354
|
+
transition-delay: 0s;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** You can add your own animations by following the same pattern
|
|
359
|
+
[data-aoe='your-animation'] {
|
|
360
|
+
transform: translateX(-45px);
|
|
361
|
+
transition:
|
|
362
|
+
transform 600ms,
|
|
363
|
+
opacity 900ms;
|
|
364
|
+
|
|
365
|
+
&.aoe {
|
|
366
|
+
transform: translateX(0);
|
|
367
|
+
transition-delay: 0s;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
**/
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,gBAAgB,CAAC;AAE5C,eAAe,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<script>import "./animations.css";
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
export let root = null;
|
|
4
|
+
export let rootMargin = "0px";
|
|
5
|
+
export let threshold = 0.3;
|
|
6
|
+
onMount(() => {
|
|
7
|
+
const ELEMENTS_TO_LOAD_IN = /* @__PURE__ */ new Set([...document.querySelectorAll("[data-aoe]")]);
|
|
8
|
+
const OBSERVER_OPTIONS = {
|
|
9
|
+
root,
|
|
10
|
+
rootMargin,
|
|
11
|
+
threshold
|
|
12
|
+
};
|
|
13
|
+
function observerCallback(entries) {
|
|
14
|
+
entries.forEach((entry) => {
|
|
15
|
+
if (entry.isIntersecting) {
|
|
16
|
+
entry.target.classList.add("aoe");
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const OBSERVER = new IntersectionObserver(observerCallback, OBSERVER_OPTIONS);
|
|
21
|
+
ELEMENTS_TO_LOAD_IN.forEach((el) => OBSERVER.observe(el));
|
|
22
|
+
});
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<!--
|
|
26
|
+
@component
|
|
27
|
+
### AnimationOnEnter (AOE)
|
|
28
|
+
This component is used to animate elements when they enter the viewport with the help of [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@param {Document | Element | null | undefined} `root` - The element that is used as the viewport for checking visibility of the target. Must be the ancestor of the target. Defaults to the browser viewport if not specified or if null. Defaults to null (browser viewport).
|
|
33
|
+
@param {string | undefined} `rootMargin` - Margin around the root. Can have values similar to the CSS margin property, e.g. "10px 20px 30px 40px" (top, right, bottom, left). The values can be percentages. Defaults to '0px' (no margin).
|
|
34
|
+
@param {number | number[]} `threshold` - Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed. A value of 0.0 indicates that even a single pixel of the target is visible. A value of 1.0 indicates that the target is completely visible. Defaults to 0.3 (30%).
|
|
35
|
+
-->
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import './animations.css';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
root?: Document | Element | null | undefined;
|
|
6
|
+
rootMargin?: string | undefined;
|
|
7
|
+
threshold?: number | number[] | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
[evt: string]: CustomEvent<any>;
|
|
11
|
+
};
|
|
12
|
+
slots: {};
|
|
13
|
+
};
|
|
14
|
+
export type IndexProps = typeof __propDef.props;
|
|
15
|
+
export type IndexEvents = typeof __propDef.events;
|
|
16
|
+
export type IndexSlots = typeof __propDef.slots;
|
|
17
|
+
/**
|
|
18
|
+
* ### AnimationOnEnter (AOE)
|
|
19
|
+
* This component is used to animate elements when they enter the viewport with the help of [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API).
|
|
20
|
+
*
|
|
21
|
+
*
|
|
22
|
+
*
|
|
23
|
+
* @param {Document | Element | null | undefined} `root` - The element that is used as the viewport for checking visibility of the target. Must be the ancestor of the target. Defaults to the browser viewport if not specified or if null. Defaults to null (browser viewport).
|
|
24
|
+
* @param {string | undefined} `rootMargin` - Margin around the root. Can have values similar to the CSS margin property, e.g. "10px 20px 30px 40px" (top, right, bottom, left). The values can be percentages. Defaults to '0px' (no margin).
|
|
25
|
+
* @param {number | number[]} `threshold` - Either a single number or an array of numbers which indicate at what percentage of the target's visibility the observer's callback should be executed. A value of 0.0 indicates that even a single pixel of the target is visible. A value of 1.0 indicates that the target is completely visible. Defaults to 0.3 (30%).
|
|
26
|
+
*/
|
|
27
|
+
export default class Index extends SvelteComponentTyped<IndexProps, IndexEvents, IndexSlots> {
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=index.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/index.svelte"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAE5C;AACD,OAAO,kBAAkB,CAAC;AAyC1B,QAAA,MAAM,SAAS;;eADyE,QAAQ,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS;qBAAe,MAAM,GAAG,SAAS;oBAAc,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS;;;;;;CAClJ,CAAC;AACxD,MAAM,MAAM,UAAU,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAChD,MAAM,MAAM,WAAW,GAAG,OAAO,SAAS,CAAC,MAAM,CAAC;AAClD,MAAM,MAAM,UAAU,GAAG,OAAO,SAAS,CAAC,KAAK,CAAC;AAEhD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,oBAAoB,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC;CAC3F"}
|
package/package.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@castlenine/svelte-aoe",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "A Svelte component to animate elements, without dependencies.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"animate-on-scroll",
|
|
8
|
+
"animate",
|
|
9
|
+
"animation-on-scroll",
|
|
10
|
+
"animation",
|
|
11
|
+
"css",
|
|
12
|
+
"svelte"
|
|
13
|
+
],
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Alexandre Castlenine",
|
|
16
|
+
"url": "https://github.com/Castlenine"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/castlenine/svelte-aoe",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/castlenine/svelte-aoe.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/castlenine/svelte-aoe/issues"
|
|
25
|
+
},
|
|
26
|
+
"type": "module",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js",
|
|
29
|
+
"svelte": "./dist/index.js",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"svelte": "./dist/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"dev": "vite dev",
|
|
42
|
+
"build": "vite build",
|
|
43
|
+
"preview": "vite preview",
|
|
44
|
+
"package": "npm run remove-dist-folder && svelte-kit sync && svelte-package && publint",
|
|
45
|
+
"prepublishOnly": "npm run package",
|
|
46
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
47
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
48
|
+
"eslint": "eslint --ignore-path ./.eslintignore .",
|
|
49
|
+
"eslint:fix": "eslint --fix --ignore-path ./.eslintignore .",
|
|
50
|
+
"prettier": "prettier --ignore-path ./.prettierignore --check .",
|
|
51
|
+
"prettier:fix": "prettier --ignore-path ./.prettierignore --write .",
|
|
52
|
+
"stylelint": "stylelint **/*.{css,scss,sass,html,js,md,mjs,svelte,svg,ts}",
|
|
53
|
+
"clean-code": "npm run stylelint && npm run prettier:fix && npm run eslint:fix",
|
|
54
|
+
"remove-dist-folder": "rimraf dist",
|
|
55
|
+
"publish-package": "npm publish -access public"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"svelte": "^3.54.0 || ^4.0.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@sveltejs/adapter-static": "^2.0.3",
|
|
62
|
+
"@sveltejs/kit": "^1.30.4",
|
|
63
|
+
"@sveltejs/package": "^2.3.1",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^7.8.0",
|
|
65
|
+
"@typescript-eslint/parser": "^7.8.0",
|
|
66
|
+
"eslint": "^8.57.0",
|
|
67
|
+
"eslint-config-prettier": "^9.1.0",
|
|
68
|
+
"eslint-import-resolver-typescript": "^3.6.1",
|
|
69
|
+
"eslint-plugin-html": "^8.1.1",
|
|
70
|
+
"eslint-plugin-import": "^2.29.1",
|
|
71
|
+
"eslint-plugin-no-loops": "^0.3.0",
|
|
72
|
+
"eslint-plugin-only-warn": "^1.1.0",
|
|
73
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
74
|
+
"eslint-plugin-security": "^1.7.1",
|
|
75
|
+
"eslint-plugin-svelte": "^2.38.0",
|
|
76
|
+
"prettier": "^3.2.5",
|
|
77
|
+
"prettier-eslint": "^16.3.0",
|
|
78
|
+
"prettier-eslint-cli": "^8.0.1",
|
|
79
|
+
"prettier-plugin-svelte": "^3.2.3",
|
|
80
|
+
"prettier-stylelint": "^0.4.2",
|
|
81
|
+
"publint": "^0.2.7",
|
|
82
|
+
"rimraf": "^5.0.5",
|
|
83
|
+
"stylelint": "^15.11.0",
|
|
84
|
+
"stylelint-config-html": "^1.1.0",
|
|
85
|
+
"stylelint-config-standard": "^34.0.0",
|
|
86
|
+
"stylelint-no-unsupported-browser-features": "^7.0.0",
|
|
87
|
+
"stylelint-order": "^6.0.4",
|
|
88
|
+
"stylelint-scss": "^5.3.2",
|
|
89
|
+
"stylelint-selector-bem-pattern": "^3.0.1",
|
|
90
|
+
"svelte": "^4.2.15",
|
|
91
|
+
"svelte-check": "^3.7.1",
|
|
92
|
+
"svelte-eslint-parser": "^0.35.0",
|
|
93
|
+
"svelte-preprocess": "^5.1.4",
|
|
94
|
+
"tslib": "^2.6.2",
|
|
95
|
+
"typescript": "^5.4.5",
|
|
96
|
+
"vite": "^4.5.3"
|
|
97
|
+
}
|
|
98
|
+
}
|