svelte-aos 0.0.3 → 0.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/README.md +205 -176
- package/dist/{no-mutation/AOS.svelte → AOS.svelte} +1 -1
- package/dist/{no-mutation/AOS.svelte.d.ts → AOS.svelte.d.ts} +1 -1
- package/dist/aos.d.ts +8 -63
- package/dist/aos.js +102 -163
- package/dist/aos.ts.old +243 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +13 -0
- package/package.json +6 -7
- package/dist/no-mutation/aos.d.ts +0 -15
- package/dist/no-mutation/aos.js +0 -143
- package/dist/no-mutation/index.d.ts +0 -2
- package/dist/no-mutation/index.js +0 -2
package/README.md
CHANGED
|
@@ -2,234 +2,288 @@
|
|
|
2
2
|
|
|
3
3
|
Animate On Scroll library for Svelte 5. Trigger CSS animations when elements scroll into view.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This package will give you an easy way to bring scroll-based animations to your Svelte applications using a simple and flexible API.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
<script>
|
|
9
|
-
import { aosObserver } from 'svelte-aos';
|
|
10
|
-
import 'svelte-aos/styles/full.css';
|
|
11
|
-
</script>
|
|
7
|
+
## ✨ Why AOS Svelte?
|
|
12
8
|
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
- ⚡ **Tiny** — <1KB gzipped JavaScript + <1kb modular CSS
|
|
10
|
+
- 🎯 **Optimized Bundle** — Import only what you need for minimal footprint
|
|
11
|
+
- 🚀 **Zero Dependencies** — No external dependencies
|
|
12
|
+
- 🔧 **Universal Compatibility** — Svelte 4 & 5 support (Actions or Attachments)
|
|
13
|
+
- ⚙️ **Highly Performant** — Only tracks and animates elements explicitly marked for animation
|
|
14
|
+
- 🎨 **Fully Customizable** — 30+ pre-built animations with flexible configuration
|
|
17
15
|
|
|
18
16
|
## Installation
|
|
19
17
|
|
|
20
18
|
```bash
|
|
21
19
|
npm install svelte-aos
|
|
20
|
+
# or
|
|
21
|
+
pnpm add svelte-aos
|
|
22
|
+
# or
|
|
23
|
+
yarn add svelte-aos
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
##
|
|
26
|
+
## Quick Start
|
|
25
27
|
|
|
26
|
-
### 1. Import
|
|
28
|
+
### 1. Import the styles
|
|
27
29
|
|
|
28
30
|
```js
|
|
29
|
-
//
|
|
31
|
+
// Import all animations
|
|
30
32
|
import 'svelte-aos/styles/full.css';
|
|
31
33
|
|
|
32
|
-
// Or
|
|
34
|
+
// Or import only what you need for smaller bundle
|
|
33
35
|
import 'svelte-aos/styles/base.css'; // Required
|
|
34
|
-
import 'svelte-aos/styles/fade.css'; //
|
|
35
|
-
import 'svelte-aos/styles/zoom.css'; // Optional
|
|
36
|
-
import 'svelte-aos/styles/flip.css'; // Optional
|
|
37
|
-
import 'svelte-aos/styles/slide.css'; // Optional
|
|
38
|
-
import 'svelte-aos/styles/easings.css'; // Optional
|
|
36
|
+
import 'svelte-aos/styles/fade.css'; // Only fade animations
|
|
39
37
|
```
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
Or in CSS:
|
|
42
40
|
|
|
43
|
-
|
|
41
|
+
```css
|
|
42
|
+
/* Import all animations */
|
|
43
|
+
@import 'svelte-aos/styles/full.css';
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
</main>
|
|
45
|
+
/* Or import only what you need */
|
|
46
|
+
@import 'svelte-aos/styles/base.css'; /* Required */
|
|
47
|
+
@import 'svelte-aos/styles/fade.css'; /* Only fade animations */
|
|
49
48
|
```
|
|
50
49
|
|
|
51
|
-
|
|
50
|
+
### 2. Add the AOS component to your page or layout
|
|
52
51
|
|
|
53
|
-
```
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
</
|
|
52
|
+
```html
|
|
53
|
+
<script>
|
|
54
|
+
import { aosAttachment, aosAction, AOS } from 'svelte-aos';
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<AOS options={{ /* options */ }} />
|
|
58
|
+
|
|
59
|
+
<!-- Rest of your page or layout -->
|
|
57
60
|
```
|
|
58
61
|
|
|
59
|
-
### 3. Add
|
|
62
|
+
### 3. Add animations to elements
|
|
60
63
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
<
|
|
64
|
+
**Svelte 5.29+ (attachment):**
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<script>
|
|
68
|
+
import { aosAttachment } from 'svelte-aos';
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<!-- Add data-aos only if you want the element to animate on first load when in viewport -->
|
|
72
|
+
<h2 data-aos="fade-up" {@attach aosAttachment({ animation: 'fade-up' })}>
|
|
73
|
+
AOS The Svelte Way
|
|
74
|
+
</h2>
|
|
65
75
|
```
|
|
66
76
|
|
|
67
|
-
|
|
77
|
+
**Svelte 4.x to 5.28 (action):**
|
|
68
78
|
|
|
69
|
-
```
|
|
79
|
+
```html
|
|
70
80
|
<script>
|
|
71
|
-
|
|
72
|
-
const attrs = toAosAttributes({
|
|
73
|
-
animation: 'fade-up',
|
|
74
|
-
delay: 150,
|
|
75
|
-
duration: 400,
|
|
76
|
-
once: true
|
|
77
|
-
});
|
|
81
|
+
import { aosAction } from 'svelte-aos';
|
|
78
82
|
</script>
|
|
79
83
|
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
Animated
|
|
84
|
-
</div>
|
|
84
|
+
<h2 data-aos="fade" use:aosAction={{ animation: 'fade' }}>
|
|
85
|
+
AOS The Svelte Way
|
|
86
|
+
</h2>
|
|
85
87
|
```
|
|
86
88
|
|
|
87
|
-
## Animations
|
|
89
|
+
## Available Animations
|
|
88
90
|
|
|
89
91
|
### Fade
|
|
90
92
|
|
|
91
|
-
|
|
93
|
+
Opacity + optional translate
|
|
94
|
+
|
|
95
|
+
```
|
|
92
96
|
fade fade-up fade-down fade-left fade-right
|
|
93
97
|
fade-up-left fade-up-right fade-down-left fade-down-right
|
|
94
98
|
```
|
|
95
99
|
|
|
96
100
|
### Zoom
|
|
97
101
|
|
|
98
|
-
|
|
102
|
+
Scale + optional translate
|
|
103
|
+
|
|
104
|
+
```
|
|
99
105
|
zoom-in zoom-in-up zoom-in-down zoom-in-left zoom-in-right
|
|
100
106
|
zoom-out zoom-out-up zoom-out-down zoom-out-left zoom-out-right
|
|
101
107
|
```
|
|
102
108
|
|
|
103
109
|
### Flip
|
|
104
110
|
|
|
105
|
-
|
|
111
|
+
3D rotation effects
|
|
112
|
+
|
|
113
|
+
```
|
|
106
114
|
flip-up flip-down flip-left flip-right
|
|
107
115
|
```
|
|
108
116
|
|
|
109
117
|
### Slide
|
|
110
118
|
|
|
111
|
-
|
|
119
|
+
Translate from edge (no opacity)
|
|
120
|
+
|
|
121
|
+
```
|
|
112
122
|
slide-up slide-down slide-left slide-right
|
|
113
123
|
```
|
|
114
124
|
|
|
115
125
|
## Per-Element Options
|
|
116
126
|
|
|
117
|
-
|
|
118
|
-
<!-- Duration (ms) -->
|
|
119
|
-
<div data-aos="fade" data-aos-duration="1000">Slow fade</div>
|
|
127
|
+
Customize each element with attachment or action parameters:
|
|
120
128
|
|
|
121
|
-
|
|
122
|
-
<div data-aos="fade" data-aos-delay="300">Delayed</div>
|
|
129
|
+
### Duration
|
|
123
130
|
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
```svelte
|
|
132
|
+
<!-- Svelte 5.29+ -->
|
|
133
|
+
<div data-aos="fade" {@attach aosAttachment({ animation: 'fade', duration: 1000 })}>
|
|
126
134
|
|
|
127
|
-
<!--
|
|
128
|
-
<div data-aos="fade"
|
|
135
|
+
<!-- Svelte 4.x to 5.28 -->
|
|
136
|
+
<div data-aos="fade" use:aosAction={{ animation: 'fade', duration: 1000 }}>
|
|
129
137
|
```
|
|
130
138
|
|
|
131
|
-
###
|
|
139
|
+
### Delay
|
|
132
140
|
|
|
133
141
|
```svelte
|
|
134
|
-
|
|
135
|
-
<div data-aos="fade
|
|
136
|
-
|
|
142
|
+
<!-- Svelte 5.29+ -->
|
|
143
|
+
<div data-aos="fade" {@attach aosAttachment({ animation: 'fade', delay: 300 })}>
|
|
144
|
+
|
|
145
|
+
<!-- Svelte 4.x to 5.28 -->
|
|
146
|
+
<div data-aos="fade" use:aosAction={{ animation: 'fade', delay: 300 }}>
|
|
137
147
|
```
|
|
138
148
|
|
|
139
|
-
|
|
149
|
+
### Easing
|
|
140
150
|
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
ease-in-quart ease-out-quart ease-in-out-quart
|
|
151
|
+
```svelte
|
|
152
|
+
<!-- Svelte 5.29+ -->
|
|
153
|
+
<div data-aos="fade" {@attach aosAttachment({ animation: 'fade', easing: 'ease-out-back' })}>
|
|
154
|
+
|
|
155
|
+
<!-- Svelte 4.x to 5.28 -->
|
|
156
|
+
<div data-aos="fade" use:aosAction={{ animation: 'fade', easing: 'ease-out-back' }}>
|
|
148
157
|
```
|
|
149
158
|
|
|
150
|
-
|
|
159
|
+
### Animate Once
|
|
151
160
|
|
|
152
161
|
```svelte
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
easing: 'ease', // default easing
|
|
159
|
-
once: false, // animate only once
|
|
160
|
-
disable: false, // disable all animations
|
|
161
|
-
anchorPlacement: 'top-bottom'
|
|
162
|
-
})}>
|
|
162
|
+
<!-- Svelte 5.29+ -->
|
|
163
|
+
<div data-aos="fade" {@attach aosAttachment({ animation: 'fade', once: true })}>
|
|
164
|
+
|
|
165
|
+
<!-- Svelte 4.x to 5.28 -->
|
|
166
|
+
<div data-aos="fade" use:aosAction={{ animation: 'fade', once: true }}>
|
|
163
167
|
```
|
|
164
168
|
|
|
165
|
-
###
|
|
169
|
+
### Staggered Animation
|
|
166
170
|
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
|
|
171
|
+
```svelte
|
|
172
|
+
<div data-aos="fade-up" {@attach aosAttachment({ animation: 'fade-up', delay: 0 })}>First</div>
|
|
173
|
+
<div data-aos="fade-up" {@attach aosAttachment({ animation: 'fade-up', delay: 100 })}>Second</div>
|
|
174
|
+
<div data-aos="fade-up" {@attach aosAttachment({ animation: 'fade-up', delay: 200 })}>Third</div>
|
|
175
|
+
```
|
|
170
176
|
|
|
171
|
-
|
|
172
|
-
aosObserver({ disable: true });
|
|
177
|
+
## Available Easings
|
|
173
178
|
|
|
174
|
-
|
|
175
|
-
|
|
179
|
+
```
|
|
180
|
+
linear ease ease-in ease-out ease-in-out
|
|
181
|
+
ease-in-back ease-out-back ease-in-out-back
|
|
182
|
+
ease-in-sine ease-out-sine ease-in-out-sine
|
|
183
|
+
ease-in-quad ease-out-quad ease-in-out-quad
|
|
184
|
+
ease-in-cubic ease-out-cubic ease-in-out-cubic
|
|
185
|
+
ease-in-quart ease-out-quart ease-in-out-quart
|
|
176
186
|
```
|
|
177
187
|
|
|
178
|
-
## API
|
|
188
|
+
## API Reference
|
|
179
189
|
|
|
180
|
-
###
|
|
190
|
+
### `<AOS />` Component
|
|
181
191
|
|
|
182
|
-
|
|
192
|
+
Add once at the top level of your page or layout. Configures global defaults.
|
|
183
193
|
|
|
184
194
|
```svelte
|
|
185
|
-
<
|
|
186
|
-
|
|
187
|
-
|
|
195
|
+
<AOS
|
|
196
|
+
options={{
|
|
197
|
+
offset: 120, // Offset from viewport edge (px)
|
|
198
|
+
delay: 0, // Default delay before animation (ms)
|
|
199
|
+
duration: 400, // Default animation duration (ms)
|
|
200
|
+
easing: 'ease', // Default easing function
|
|
201
|
+
once: false, // Animate only once per element
|
|
202
|
+
anchorPlacement: 'top-bottom', // Which position triggers animation
|
|
203
|
+
disable: false, // Disable all animations
|
|
204
|
+
threshold: 0.1 // IntersectionObserver visibility threshold (0-1)
|
|
205
|
+
}}
|
|
206
|
+
/>
|
|
188
207
|
```
|
|
189
208
|
|
|
190
|
-
###
|
|
209
|
+
### `aosAttachment` (Svelte 5.29+)
|
|
191
210
|
|
|
192
|
-
Svelte
|
|
211
|
+
Svelte 5 attachment for individual elements.
|
|
193
212
|
|
|
194
213
|
```svelte
|
|
195
|
-
<
|
|
196
|
-
|
|
197
|
-
|
|
214
|
+
<div
|
|
215
|
+
data-aos="fade-up"
|
|
216
|
+
{@attach aosAttachment({
|
|
217
|
+
animation: 'fade-up',
|
|
218
|
+
delay: 150,
|
|
219
|
+
duration: 400,
|
|
220
|
+
once: true
|
|
221
|
+
})}
|
|
222
|
+
>
|
|
223
|
+
Animated
|
|
224
|
+
</div>
|
|
198
225
|
```
|
|
199
226
|
|
|
200
|
-
###
|
|
227
|
+
### `aosAction` (Svelte 4.x to 5.28)
|
|
201
228
|
|
|
202
|
-
|
|
229
|
+
Svelte action for individual elements.
|
|
203
230
|
|
|
204
231
|
```svelte
|
|
205
|
-
<
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
232
|
+
<div
|
|
233
|
+
data-aos="fade-up"
|
|
234
|
+
use:aosAction={{
|
|
235
|
+
animation: 'fade-up',
|
|
236
|
+
delay: 150,
|
|
237
|
+
duration: 400,
|
|
238
|
+
once: true
|
|
239
|
+
}}
|
|
240
|
+
>
|
|
241
|
+
Animated
|
|
242
|
+
</div>
|
|
243
|
+
```
|
|
215
244
|
|
|
216
|
-
|
|
245
|
+
> 💡 **Note:** The `data-aos` attribute is only needed if you want the element to animate on first page load when already visible in the viewport.
|
|
217
246
|
|
|
218
|
-
|
|
219
|
-
|
|
247
|
+
### Disable Option
|
|
248
|
+
|
|
249
|
+
Disable all animations globally via the `<AOS />` component:
|
|
250
|
+
|
|
251
|
+
```svelte
|
|
252
|
+
<AOS
|
|
253
|
+
options={{
|
|
254
|
+
// Disable on specific device type
|
|
255
|
+
disable: 'mobile' // 'mobile' | 'phone' | 'tablet'
|
|
256
|
+
|
|
257
|
+
// Or disable entirely
|
|
258
|
+
disable: true
|
|
259
|
+
|
|
260
|
+
// Or use a custom function
|
|
261
|
+
disable: () => window.innerWidth < 768
|
|
262
|
+
}}
|
|
263
|
+
/>
|
|
220
264
|
```
|
|
221
265
|
|
|
222
|
-
## CSS
|
|
266
|
+
## Selective CSS Imports
|
|
267
|
+
|
|
268
|
+
Only import the animations you use to reduce bundle size:
|
|
269
|
+
|
|
270
|
+
| File | Animations | Required |
|
|
271
|
+
| ------------- | ----------------------------------------- | ----------- |
|
|
272
|
+
| `base.css` | Core setup, CSS variables, reduced motion | ✅ Yes |
|
|
273
|
+
| `fade.css` | fade, fade-up, fade-down, etc. | Optional |
|
|
274
|
+
| `zoom.css` | zoom-in, zoom-out variants | Optional |
|
|
275
|
+
| `flip.css` | flip-up, flip-down, etc. | Optional |
|
|
276
|
+
| `slide.css` | slide-up, slide-down, etc. | Optional |
|
|
277
|
+
| `easings.css` | Custom easing functions | Optional |
|
|
278
|
+
| `full.css` | Everything bundled | Convenience |
|
|
223
279
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
| `easings.css` | Custom easing functions |
|
|
232
|
-
| `full.css` | All of the above |
|
|
280
|
+
**Example: Only fade animations with custom easings**
|
|
281
|
+
|
|
282
|
+
```js
|
|
283
|
+
import 'svelte-aos/styles/base.css';
|
|
284
|
+
import 'svelte-aos/styles/fade.css';
|
|
285
|
+
import 'svelte-aos/styles/easings.css';
|
|
286
|
+
```
|
|
233
287
|
|
|
234
288
|
## Examples
|
|
235
289
|
|
|
@@ -237,68 +291,43 @@ Generate attributes programmatically:
|
|
|
237
291
|
|
|
238
292
|
```svelte
|
|
239
293
|
<script>
|
|
240
|
-
import {
|
|
294
|
+
import { aosAttachment, AOS } from 'svelte-aos';
|
|
241
295
|
import 'svelte-aos/styles/full.css';
|
|
242
296
|
</script>
|
|
243
297
|
|
|
244
|
-
<
|
|
298
|
+
<AOS config={{ once: true, disable: 'mobile' }} />
|
|
299
|
+
|
|
300
|
+
<main>
|
|
245
301
|
<section>
|
|
246
|
-
<h1 data-aos="fade-down">Welcome</h1>
|
|
247
|
-
<p data-aos="fade-up"
|
|
302
|
+
<h1 data-aos="fade-down" {@attach aosAttachment({ animation: 'fade-down' })}>Welcome</h1>
|
|
303
|
+
<p data-aos="fade-up" {@attach aosAttachment({ animation: 'fade-up', delay: 100 })}>
|
|
304
|
+
Scroll to see more
|
|
305
|
+
</p>
|
|
248
306
|
</section>
|
|
249
307
|
|
|
250
308
|
<section>
|
|
251
|
-
<div data-aos="fade-right">Card 1</div>
|
|
252
|
-
<div data-aos="fade-right"
|
|
253
|
-
|
|
309
|
+
<div data-aos="fade-right" {@attach aosAttachment({ animation: 'fade-right' })}>Card 1</div>
|
|
310
|
+
<div data-aos="fade-right" {@attach aosAttachment({ animation: 'fade-right', delay: 100 })}>
|
|
311
|
+
Card 2
|
|
312
|
+
</div>
|
|
313
|
+
<div data-aos="fade-right" {@attach aosAttachment({ animation: 'fade-right', delay: 200 })}>
|
|
314
|
+
Card 3
|
|
315
|
+
</div>
|
|
254
316
|
</section>
|
|
255
317
|
</main>
|
|
256
318
|
```
|
|
257
319
|
|
|
258
|
-
###
|
|
259
|
-
|
|
260
|
-
```svelte
|
|
261
|
-
<main {@attach aosObserver({ once: true })}>
|
|
262
|
-
<div data-aos="zoom-in">Animates once, stays visible</div>
|
|
263
|
-
</main>
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
### With Dynamic Content
|
|
320
|
+
### With Custom Easing
|
|
267
321
|
|
|
268
322
|
```svelte
|
|
269
|
-
<
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
let items = $state([]);
|
|
274
|
-
|
|
275
|
-
async function loadMore() {
|
|
276
|
-
items = [...items, ...(await fetchItems())];
|
|
277
|
-
}
|
|
278
|
-
</script>
|
|
279
|
-
|
|
280
|
-
<!-- MutationObserver auto-detects new [data-aos] elements -->
|
|
281
|
-
<main {@attach aosObserver()}>
|
|
282
|
-
{#each items as item, i}
|
|
283
|
-
<div data-aos="fade-up" data-aos-delay={i * 50}>{item.name}</div>
|
|
284
|
-
{/each}
|
|
285
|
-
<button onclick={loadMore}>Load More</button>
|
|
286
|
-
</main>
|
|
323
|
+
<div data-aos="zoom-in" {@attach aosAttachment({ animation: 'zoom-in', easing: 'ease-out-back' })}>
|
|
324
|
+
Bouncy zoom effect
|
|
325
|
+
</div>
|
|
287
326
|
```
|
|
288
327
|
|
|
289
|
-
###
|
|
328
|
+
### Contributing
|
|
290
329
|
|
|
291
|
-
|
|
292
|
-
<script>
|
|
293
|
-
import { aosObserver } from 'svelte-aos';
|
|
294
|
-
import 'svelte-aos/styles/base.css';
|
|
295
|
-
import 'svelte-aos/styles/fade.css';
|
|
296
|
-
</script>
|
|
297
|
-
|
|
298
|
-
<main {@attach aosObserver()}>
|
|
299
|
-
<div data-aos="fade-up">Only fade animations available</div>
|
|
300
|
-
</main>
|
|
301
|
-
```
|
|
330
|
+
Contributions, issues, and feature requests are welcome! No formal contribution process is set up yet, but feel free to open issues or submit pull requests.
|
|
302
331
|
|
|
303
332
|
## License
|
|
304
333
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AOSOptions } from '
|
|
1
|
+
import type { AOSOptions } from './types.ts';
|
|
2
2
|
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
3
|
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
4
|
$$bindings?: Bindings;
|
package/dist/aos.d.ts
CHANGED
|
@@ -1,70 +1,15 @@
|
|
|
1
|
-
import type { AnimationType,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* The attachment will:
|
|
7
|
-
* - Apply per-element CSS variables (duration/delay) from `data-aos-*` attributes
|
|
8
|
-
* or from the `params` defaults.
|
|
9
|
-
* - Add the `.aos-animate` class when the element meets the `threshold`/`rootMargin` criteria.
|
|
10
|
-
* - Remove `.aos-animate` on exit unless `once` is true (or element has `data-aos-once="true").
|
|
11
|
-
* - If `once` is true, the element will be unobserved after its first entry.
|
|
12
|
-
* - Applies `params.easing` to elements that do not have `data-aos-easing` set.
|
|
13
|
-
*
|
|
14
|
-
* @param {Object} [params] - Global observer and animation options.
|
|
15
|
-
*/
|
|
16
|
-
export declare function aosObserver(params?: {
|
|
1
|
+
import type { AnimationType, AOSOptions, EasingType } from './types.ts';
|
|
2
|
+
export declare function initAOS(options?: AOSOptions): void;
|
|
3
|
+
export type AOSElementOptions = {
|
|
4
|
+
animation?: AnimationType;
|
|
17
5
|
duration?: number;
|
|
18
|
-
threshold?: number;
|
|
19
6
|
delay?: number;
|
|
20
|
-
once?: boolean;
|
|
21
|
-
disable?: DisableOption;
|
|
22
|
-
anchorPlacement?: AnchorPlacement;
|
|
23
|
-
offset?: number;
|
|
24
7
|
easing?: EasingType;
|
|
25
|
-
}): (node: HTMLElement) => () => void;
|
|
26
|
-
/**
|
|
27
|
-
* This is to use if attachements are not available in your svelte setup.
|
|
28
|
-
* @param node - HTML element to attach AOS behavior to
|
|
29
|
-
*
|
|
30
|
-
* @param params - AOS options
|
|
31
|
-
* @returns
|
|
32
|
-
*/
|
|
33
|
-
export declare function aosAction(node: HTMLElement, params?: {
|
|
34
|
-
duration?: number;
|
|
35
|
-
threshold?: number;
|
|
36
|
-
delay?: number;
|
|
37
8
|
once?: boolean;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}): {
|
|
9
|
+
distance?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function aosAttachment(options?: AOSElementOptions): (node: HTMLElement) => () => void | undefined;
|
|
12
|
+
export declare function aosAction(node: HTMLElement, options?: AOSElementOptions): {
|
|
43
13
|
update: () => void;
|
|
44
14
|
destroy(): void;
|
|
45
15
|
};
|
|
46
|
-
/**
|
|
47
|
-
* Convert a small configuration object into a map of `data-aos-*` attributes.
|
|
48
|
-
*
|
|
49
|
-
* Useful for demos or programmatically attaching attributes to an element (e.g. in Svelte
|
|
50
|
-
* you can spread the returned object with `{...toAosAttributes({...})}`).
|
|
51
|
-
*
|
|
52
|
-
* @param {Object} options - Per-element options
|
|
53
|
-
* @param {number} [options.delay] - Delay in ms
|
|
54
|
-
* @param {number} [options.duration] - Duration in ms
|
|
55
|
-
* @param {EasingType} [options.easing] - Easing name
|
|
56
|
-
* @param {AnimationType} [options.animation] - Animation name
|
|
57
|
-
* @param {boolean} [options.once] - If true, set `data-aos-once` on the element
|
|
58
|
-
* @returns {Record<string,string>} Map of attributes (keys are attribute names, values are strings)
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* const attrs = toAosAttributes({ animation: 'fade-up', delay: 150, duration: 400 });
|
|
62
|
-
* // => { 'data-aos': 'fade-up', 'data-aos-delay': '150', 'data-aos-duration': '400' }
|
|
63
|
-
*/
|
|
64
|
-
export declare function toAosAttributes(options: {
|
|
65
|
-
delay?: number;
|
|
66
|
-
duration?: number;
|
|
67
|
-
easing?: EasingType;
|
|
68
|
-
animation?: AnimationType;
|
|
69
|
-
once?: boolean;
|
|
70
|
-
}): Record<string, string>;
|