@@ -316,208 +316,11 @@ Each keyframe object contains an `offset` property. `offset` is a value between
316
316
317
317
Multiple elements can be animated at the same time and controlled via a single parent animation object. Child animations inherit properties such as duration, easing, and iterations unless otherwise specified. A parent animation's ` onFinish ` callback will not be called until all child animations have completed.
318
318
319
- ### Usage
320
-
321
- ```` mdx-code-block
322
- <Tabs
323
- groupId="framework"
324
- defaultValue="javascript"
325
- values={[
326
- { value: 'javascript', label: 'JavaScript' },
327
- { value: 'angular', label: 'Angular' },
328
- { value: 'react', label: 'React' },
329
- { value: 'vue', label: 'Vue' },
330
- ]
331
- }>
332
- <TabItem value="javascript">
333
-
334
- ```javascript
335
- const squareA = createAnimation()
336
- .addElement(document.querySelector('.square-a'))
337
- .keyframes([
338
- { offset: 0, transform: 'scale(1) rotate(0)' },
339
- { offset: 0.5, transform: 'scale(1.2) rotate(45deg)' },
340
- { offset: 1, transform: 'scale(1) rotate(45deg)' }
341
- ]);
342
-
343
- const squareB = createAnimation()
344
- .addElement(document.querySelector('.square-b'))
345
- .keyframes([
346
- { offset: 0, transform: 'scale(1))', opacity: '1' },
347
- { offset: 0.5, transform: 'scale(1.2)', opacity: '0.3' },
348
- { offset: 1, transform: 'scale(1)', opacity: '1' }
349
- ]);
350
-
351
- const squareC = createAnimation()
352
- .addElement(document.querySelector('.square-c'))
353
- .duration(5000)
354
- .keyframes([
355
- { offset: 0, transform: 'scale(1))', opacity: '0.5' },
356
- { offset: 0.5, transform: 'scale(0.8)', opacity: '1' },
357
- { offset: 1, transform: 'scale(1)', opacity: '0.5' }
358
- ]);
359
-
360
- const parent = createAnimation()
361
- .duration(2000)
362
- .iterations(Infinity)
363
- .addAnimation([squareA, squareB, squareC]);
364
- ```
365
-
366
- </TabItem>
367
- <TabItem value="angular">
368
-
369
- ```javascript
370
- const squareA = this.animationCtrl.create()
371
- .addElement(this.squareA.nativeElement)
372
- .keyframes([
373
- { offset: 0, transform: 'scale(1) rotate(0)' },
374
- { offset: 0.5, transform: 'scale(1.2) rotate(45deg)' },
375
- { offset: 1, transform: 'scale(1) rotate(45deg)' }
376
- ]);
377
-
378
- const squareB = this.animationCtrl.create()
379
- .addElement(this.squareB.nativeElement)
380
- .keyframes([
381
- { offset: 0, transform: 'scale(1))', opacity: '1' },
382
- { offset: 0.5, transform: 'scale(1.2)', opacity: '0.3' },
383
- { offset: 1, transform: 'scale(1)', opacity: '1' }
384
- ]);
385
-
386
- const squareC = this.animationCtrl.create()
387
- .addElement(this.squareC.nativeElement)
388
- .duration(5000)
389
- .keyframes([
390
- { offset: 0, transform: 'scale(1))', opacity: '0.5' },
391
- { offset: 0.5, transform: 'scale(0.8)', opacity: '1' },
392
- { offset: 1, transform: 'scale(1)', opacity: '0.5' }
393
- ]);
394
-
395
- const parent = this.animationCtrl.create()
396
- .duration(2000)
397
- .iterations(Infinity)
398
- .addAnimation([squareA, squareB, squareC]);
399
- ```
400
-
401
- </TabItem>
402
- <TabItem value="react">
403
-
404
- ```tsx
405
- private parentRef: React.RefObject<CreateAnimation> = React.createRef();
406
- private squareARef: React.RefObject<CreateAnimation> = React.createRef();
407
- private squareBRef: React.RefObject<CreateAnimation> = React.createRef();
408
- private squareCRef: React.RefObject<CreateAnimation> = React.createRef();
409
-
410
- ...
411
-
412
- componentDidMount() {
413
- const parent = this.parentRef.current!.animation;
414
- const squareA = this.squareARef.current!.animation;
415
- const squareB = this.squareBRef.current!.animation;
416
- const squareC = this.squareCRef.current!.animation;
417
-
418
- parent.addAnimation([squareA, squareB, squareC]);
419
- }
420
-
421
- render() {
422
- return (
423
- <>
424
- <CreateAnimation
425
- ref={this.parentRef}
426
- duration={2000}
427
- iterations={Infinity}
428
- ></CreateAnimation>
429
-
430
- <CreateAnimation
431
- ref={this.squareARef}
432
- keyframes={[
433
- { offset: 0, transform: 'scale(1) rotate(0)' },
434
- { offset: 0.5, transform: 'scale(1.2) rotate(45deg)' },
435
- { offset: 1, transform: 'scale(1) rotate(0deg)' }
436
- ]}
437
- >
438
- <div className="square"></div>
439
- </CreateAnimation>
440
-
441
- <CreateAnimation
442
- ref={this.squareBRef}
443
- keyframes={[
444
- { offset: 0, transform: 'scale(1)', opacity: '1' },
445
- { offset: 0.5, transform: 'scale(1.2)', opacity: '0.3' },
446
- { offset: 1, transform: 'scale(1)', opacity: '1' }
447
- ]}
448
- >
449
- <div className="square"></div>
450
- </CreateAnimation>
451
-
452
- <CreateAnimation
453
- ref={this.squareCRef}
454
- duration={5000}
455
- keyframes={[
456
- { offset: 0, transform: 'scale(1)', opacity: '0.5' },
457
- { offset: 0.5, transform: 'scale(0.8)', opacity: '1' },
458
- { offset: 1, transform: 'scale(1)', opacity: '0.5' }
459
- ]}
460
- >
461
- <div className="square"></div>
462
- </CreateAnimation>
463
- </>
464
- )
465
- }
466
- ```
467
-
468
- </TabItem>
469
- <TabItem value="vue">
470
-
471
- ```javascript
472
- import { createAnimation } from '@ionic/vue';
473
- import { ref } from 'vue';
474
-
475
- ...
476
-
477
- const squareARef = ref();
478
- const squareBRef = ref();
479
- const squareCRef = ref();
480
-
481
- ...
482
-
483
- const squareA = createAnimation()
484
- .addElement(squareARef.value)
485
- .keyframes([
486
- { offset: 0, transform: 'scale(1) rotate(0)' },
487
- { offset: 0.5, transform: 'scale(1.2) rotate(45deg)' },
488
- { offset: 1, transform: 'scale(1) rotate(45deg)' }
489
- ]);
490
-
491
- const squareB = createAnimation()
492
- .addElement(squareBRef.value)
493
- .keyframes([
494
- { offset: 0, transform: 'scale(1))', opacity: '1' },
495
- { offset: 0.5, transform: 'scale(1.2)', opacity: '0.3' },
496
- { offset: 1, transform: 'scale(1)', opacity: '1' }
497
- ]);
498
-
499
- const squareC = createAnimation()
500
- .addElement(squareCRef.value)
501
- .duration(5000)
502
- .keyframes([
503
- { offset: 0, transform: 'scale(1))', opacity: '0.5' },
504
- { offset: 0.5, transform: 'scale(0.8)', opacity: '1' },
505
- { offset: 1, transform: 'scale(1)', opacity: '0.5' }
506
- ]);
507
-
508
- const parent = createAnimation()
509
- .duration(2000)
510
- .iterations(Infinity)
511
- .addAnimation([squareA, squareB, squareC]);
512
- ```
513
-
514
- </TabItem>
515
- </Tabs>
516
- ````
319
+ This example shows 3 child animations controlled by a single parent animation. Animations ` cardA ` and ` cardB ` inherit the parent animation's duration of 2000ms, but animation ` cardC ` has a duration of 5000ms since it was explicitly set.
517
320
518
- This example shows 3 child animations controlled by a single parent animation. Animations ` squareA ` and ` squareB ` inherit the parent animation's duration of 2000ms, but animation ` squareC ` has a duration of 5000ms since it was explicitly set.
321
+ import Group from ' @ site/static /usage/v7/ animations/group/index.md';
519
322
520
- <Codepen user = " ionic " slug = " oNvdogM " height = " 460 " />
323
+ <Group />
521
324
522
325
## Before and After Hooks
523
326
0 commit comments