You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 431cecc
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/utilities/animations.md
+4-109Lines changed: 4 additions & 109 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -255,118 +255,13 @@ import Group from '@site/static/usage/v7/animations/group/index.md';
255
255
256
256
Ionic Animations provides hooks that let you alter an element before an animation runs and after an animation completes. These hooks can be used to perform DOM reads and writes as well as add or remove classes and inline styles.
257
257
258
-
### Usage
259
-
260
-
````mdx-code-block
261
-
<Tabs
262
-
groupId="framework"
263
-
defaultValue="javascript"
264
-
values={[
265
-
{ value: 'javascript', label: 'JavaScript' },
266
-
{ value: 'angular', label: 'Angular' },
267
-
{ value: 'react', label: 'React' },
268
-
{ value: 'vue', label: 'Vue' },
269
-
]
270
-
}>
271
-
<TabItem value="javascript">
272
-
273
-
```javascript
274
-
createAnimation()
275
-
.addElement(document.querySelector('.square'))
276
-
.duration(2000)
277
-
.beforeStyles({
278
-
opacity: 0.2
279
-
})
280
-
.afterStyles({
281
-
background: 'rgba(0, 255, 0, 0.5)'
282
-
})
283
-
.afterClearStyles(['opacity'])
284
-
.keyframes([
285
-
{ offset: 0, transform: 'scale(1)' },
286
-
{ offset: 0.5, transform: 'scale(1.5)' },
287
-
{ offset: 1, transform: 'scale(1)' }
288
-
])
289
-
```
290
-
</TabItem>
291
-
<TabItem value="angular">
292
-
293
-
```javascript
294
-
this.animationCtrl.create()
295
-
.addElement(this.square.nativeElement)
296
-
.duration(2000)
297
-
.beforeStyles({
298
-
opacity: 0.2
299
-
})
300
-
.afterStyles({
301
-
background: 'rgba(0, 255, 0, 0.5)'
302
-
})
303
-
.afterClearStyles(['opacity'])
304
-
.keyframes([
305
-
{ offset: 0, transform: 'scale(1)' },
306
-
{ offset: 0.5, transform: 'scale(1.5)' },
307
-
{ offset: 1, transform: 'scale(1)' }
308
-
])
309
-
```
310
-
</TabItem>
311
-
<TabItem value="react">
312
-
313
-
```tsx
314
-
<CreateAnimation
315
-
duration={2000}
316
-
beforeStyles={{
317
-
opacity: 0.2
318
-
}}
319
-
afterStyles={{
320
-
background: 'rgba(0, 255, 0, 0.5)'
321
-
}}
322
-
afterClearStyles={['opacity']}
323
-
keyframes={[
324
-
{ offset: 0, transform: 'scale(1)' },
325
-
{ offset: 0.5, transform: 'scale(1.5)' },
326
-
{ offset: 1, transform: 'scale(1)' }
327
-
]}
328
-
>
329
-
...
330
-
</CreateAnimation>
331
-
```
332
-
</TabItem>
333
-
<TabItem value="vue">
334
-
335
-
```javascript
336
-
import { createAnimation } from '@ionic/vue';
337
-
import { ref } from 'vue';
338
-
339
-
...
340
-
341
-
const squareRef = ref();
342
-
343
-
...
344
-
345
-
createAnimation()
346
-
.addElement(squareRef.value)
347
-
.duration(2000)
348
-
.beforeStyles({
349
-
opacity: 0.2
350
-
})
351
-
.afterStyles({
352
-
background: 'rgba(0, 255, 0, 0.5)'
353
-
})
354
-
.afterClearStyles(['opacity'])
355
-
.keyframes([
356
-
{ offset: 0, transform: 'scale(1)' },
357
-
{ offset: 0.5, transform: 'scale(1.5)' },
358
-
{ offset: 1, transform: 'scale(1)' }
359
-
])
360
-
```
361
-
</TabItem>
362
-
</Tabs>
363
-
````
364
-
365
-
In this example, an inline opacity of 0.2 is set on the `.square` element prior to the animation starting. Once the animation finishes, the background color of the element is set to `rgba(0, 255, 0, 0.5)`, and the inline opacity is cleared.
258
+
This example sets an inline filter which inverts the background color of the card by `75%` prior to the animation starting. Once the animation finishes, the box shadow on the element is set to `rgba(255, 0, 50, 0.4) 0px 4px 16px 6px`, a red glow, and the inline filter is cleared. The animation must be stopped in order to remove the box shadow and play it with the filter again.
366
259
367
260
See [Methods](#methods) for a complete list of hooks.
368
261
369
-
<Codepenuser="ionic"slug="BaBxmwo" />
262
+
import BeforeAndAfterHooks from '@site/static/usage/v7/animations/before-and-after-hooks/index.md';
0 commit comments