From f8a5f369effb76f94881cb5bafe5419d0b568520 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 10 Jul 2023 12:33:27 -0400 Subject: [PATCH 01/13] docs(animation): add iframe and JS grouped demo --- docs/utilities/animations.md | 203 +----------------- .../group/angular/example_component_html.md | 23 ++ .../group/angular/example_component_ts.md | 52 +++++ static/usage/v7/animations/group/demo.html | 87 ++++++++ static/usage/v7/animations/group/index.md | 25 +++ .../usage/v7/animations/group/javascript.md | 49 +++++ static/usage/v7/animations/group/react.md | 71 ++++++ static/usage/v7/animations/group/vue.md | 90 ++++++++ 8 files changed, 400 insertions(+), 200 deletions(-) create mode 100644 static/usage/v7/animations/group/angular/example_component_html.md create mode 100644 static/usage/v7/animations/group/angular/example_component_ts.md create mode 100644 static/usage/v7/animations/group/demo.html create mode 100644 static/usage/v7/animations/group/index.md create mode 100644 static/usage/v7/animations/group/javascript.md create mode 100644 static/usage/v7/animations/group/react.md create mode 100644 static/usage/v7/animations/group/vue.md diff --git a/docs/utilities/animations.md b/docs/utilities/animations.md index d53bfbca0e5..728426dd6ce 100644 --- a/docs/utilities/animations.md +++ b/docs/utilities/animations.md @@ -316,208 +316,11 @@ Each keyframe object contains an `offset` property. `offset` is a value between 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. -### Usage - -````mdx-code-block - - - -```javascript -const squareA = createAnimation() - .addElement(document.querySelector('.square-a')) - .keyframes([ - { offset: 0, transform: 'scale(1) rotate(0)' }, - { offset: 0.5, transform: 'scale(1.2) rotate(45deg)' }, - { offset: 1, transform: 'scale(1) rotate(45deg)' } - ]); - -const squareB = createAnimation() - .addElement(document.querySelector('.square-b')) - .keyframes([ - { offset: 0, transform: 'scale(1))', opacity: '1' }, - { offset: 0.5, transform: 'scale(1.2)', opacity: '0.3' }, - { offset: 1, transform: 'scale(1)', opacity: '1' } - ]); - -const squareC = createAnimation() - .addElement(document.querySelector('.square-c')) - .duration(5000) - .keyframes([ - { offset: 0, transform: 'scale(1))', opacity: '0.5' }, - { offset: 0.5, transform: 'scale(0.8)', opacity: '1' }, - { offset: 1, transform: 'scale(1)', opacity: '0.5' } - ]); - -const parent = createAnimation() - .duration(2000) - .iterations(Infinity) - .addAnimation([squareA, squareB, squareC]); -``` - - - - -```javascript -const squareA = this.animationCtrl.create() - .addElement(this.squareA.nativeElement) - .keyframes([ - { offset: 0, transform: 'scale(1) rotate(0)' }, - { offset: 0.5, transform: 'scale(1.2) rotate(45deg)' }, - { offset: 1, transform: 'scale(1) rotate(45deg)' } - ]); - -const squareB = this.animationCtrl.create() - .addElement(this.squareB.nativeElement) - .keyframes([ - { offset: 0, transform: 'scale(1))', opacity: '1' }, - { offset: 0.5, transform: 'scale(1.2)', opacity: '0.3' }, - { offset: 1, transform: 'scale(1)', opacity: '1' } - ]); - -const squareC = this.animationCtrl.create() - .addElement(this.squareC.nativeElement) - .duration(5000) - .keyframes([ - { offset: 0, transform: 'scale(1))', opacity: '0.5' }, - { offset: 0.5, transform: 'scale(0.8)', opacity: '1' }, - { offset: 1, transform: 'scale(1)', opacity: '0.5' } - ]); - -const parent = this.animationCtrl.create() - .duration(2000) - .iterations(Infinity) - .addAnimation([squareA, squareB, squareC]); -``` - - - - -```tsx -private parentRef: React.RefObject = React.createRef(); -private squareARef: React.RefObject = React.createRef(); -private squareBRef: React.RefObject = React.createRef(); -private squareCRef: React.RefObject = React.createRef(); - -... - -componentDidMount() { - const parent = this.parentRef.current!.animation; - const squareA = this.squareARef.current!.animation; - const squareB = this.squareBRef.current!.animation; - const squareC = this.squareCRef.current!.animation; - - parent.addAnimation([squareA, squareB, squareC]); -} - -render() { - return ( - <> - - - -
-
- - -
-
- - -
-
- - ) -} -``` - -
- - -```javascript -import { createAnimation } from '@ionic/vue'; -import { ref } from 'vue'; - -... - -const squareARef = ref(); -const squareBRef = ref(); -const squareCRef = ref(); - -... - -const squareA = createAnimation() - .addElement(squareARef.value) - .keyframes([ - { offset: 0, transform: 'scale(1) rotate(0)' }, - { offset: 0.5, transform: 'scale(1.2) rotate(45deg)' }, - { offset: 1, transform: 'scale(1) rotate(45deg)' } - ]); - -const squareB = createAnimation() - .addElement(squareBRef.value) - .keyframes([ - { offset: 0, transform: 'scale(1))', opacity: '1' }, - { offset: 0.5, transform: 'scale(1.2)', opacity: '0.3' }, - { offset: 1, transform: 'scale(1)', opacity: '1' } - ]); - -const squareC = createAnimation() - .addElement(squareCRef.value) - .duration(5000) - .keyframes([ - { offset: 0, transform: 'scale(1))', opacity: '0.5' }, - { offset: 0.5, transform: 'scale(0.8)', opacity: '1' }, - { offset: 1, transform: 'scale(1)', opacity: '0.5' } - ]); - -const parent = createAnimation() - .duration(2000) - .iterations(Infinity) - .addAnimation([squareA, squareB, squareC]); -``` - - -
-```` - 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. - +import Group from '@site/static/usage/v7/animations/group/index.md'; + + ## Before and After Hooks diff --git a/static/usage/v7/animations/group/angular/example_component_html.md b/static/usage/v7/animations/group/angular/example_component_html.md new file mode 100644 index 00000000000..178ae34c17b --- /dev/null +++ b/static/usage/v7/animations/group/angular/example_component_html.md @@ -0,0 +1,23 @@ +```html + + + Page + + + + Present Modal + + + + + Modal + + Close + + + + Modal Content + + + +``` diff --git a/static/usage/v7/animations/group/angular/example_component_ts.md b/static/usage/v7/animations/group/angular/example_component_ts.md new file mode 100644 index 00000000000..b1fe997c1d4 --- /dev/null +++ b/static/usage/v7/animations/group/angular/example_component_ts.md @@ -0,0 +1,52 @@ +```ts +import { Component, ViewChild } from '@angular/core'; +import type { IonModal } from '@ionic/angular'; +import { AnimationController } from '@ionic/angular'; + +@Component({ + selector: 'app-example', + templateUrl: 'example.component.html', +}) +export class ExampleComponent { + @ViewChild('modal', { static: true }) modal: IonModal; + + constructor(private animationCtrl: AnimationController) {} + + ngOnInit() { + const enterAnimation = (baseEl: HTMLElement) => { + const root = baseEl.shadowRoot; + + const backdropAnimation = this.animationCtrl + .create() + .addElement(root.querySelector('ion-backdrop')) + .fromTo('opacity', '0.01', 'var(--backdrop-opacity)'); + + const wrapperAnimation = this.animationCtrl + .create() + .addElement(root.querySelector('.modal-wrapper')) + .keyframes([ + { offset: 0, opacity: '0', transform: 'scale(0)' }, + { offset: 1, opacity: '0.99', transform: 'scale(1)' }, + ]); + + return this.animationCtrl + .create() + .addElement(baseEl) + .easing('ease-out') + .duration(500) + .addAnimation([backdropAnimation, wrapperAnimation]); + }; + + const leaveAnimation = (baseEl: HTMLElement) => { + return enterAnimation(baseEl).direction('reverse'); + }; + + this.modal.enterAnimation = enterAnimation; + this.modal.leaveAnimation = leaveAnimation; + } + + closeModal() { + this.modal.dismiss(); + } +} +``` diff --git a/static/usage/v7/animations/group/demo.html b/static/usage/v7/animations/group/demo.html new file mode 100644 index 00000000000..afc81b2df8d --- /dev/null +++ b/static/usage/v7/animations/group/demo.html @@ -0,0 +1,87 @@ + + + + + + Animation + + + + + + + + + + +
+ + Card 1 + + + + Card 2 + + + + Card 2 + + +
+ Play + Pause + Stop +
+
+ + + diff --git a/static/usage/v7/animations/group/index.md b/static/usage/v7/animations/group/index.md new file mode 100644 index 00000000000..5d312219efa --- /dev/null +++ b/static/usage/v7/animations/group/index.md @@ -0,0 +1,25 @@ +import Playground from '@site/src/components/global/Playground'; + +import javascript from './javascript.md'; +import react from './react.md'; +import vue from './vue.md'; + +import angular_example_component_html from './angular/example_component_html.md'; +import angular_example_component_ts from './angular/example_component_ts.md'; + + diff --git a/static/usage/v7/animations/group/javascript.md b/static/usage/v7/animations/group/javascript.md new file mode 100644 index 00000000000..6773c61c135 --- /dev/null +++ b/static/usage/v7/animations/group/javascript.md @@ -0,0 +1,49 @@ +```html + + Card 1 + + + + Card 2 + + + + Card 2 + + +Play +Pause +Stop + + +``` diff --git a/static/usage/v7/animations/group/react.md b/static/usage/v7/animations/group/react.md new file mode 100644 index 00000000000..730881c49a9 --- /dev/null +++ b/static/usage/v7/animations/group/react.md @@ -0,0 +1,71 @@ +```tsx +import React, { useRef } from 'react'; +import { + IonButton, + IonButtons, + IonContent, + IonHeader, + IonModal, + IonToolbar, + IonTitle, + createAnimation, +} from '@ionic/react'; + +function Example() { + const modalEl = useRef(null); + + const enterAnimation = (baseEl: HTMLElement) => { + const root = baseEl.shadowRoot!; + + const backdropAnimation = createAnimation() + .addElement(root.querySelector('ion-backdrop')!) + .fromTo('opacity', '0.01', 'var(--backdrop-opacity)'); + + const wrapperAnimation = createAnimation() + .addElement(root.querySelector('.modal-wrapper')!) + .keyframes([ + { offset: 0, opacity: '0', transform: 'scale(0)' }, + { offset: 1, opacity: '0.99', transform: 'scale(1)' }, + ]); + + return createAnimation() + .addElement(baseEl) + .easing('ease-out') + .duration(500) + .addAnimation([backdropAnimation, wrapperAnimation]); + }; + + const leaveAnimation = (baseEl: HTMLElement) => { + return enterAnimation(baseEl).direction('reverse'); + }; + + const closeModal = () => { + modalEl.current?.dismiss(); + }; + + return ( + <> + + + Page + + + + Present Modal + + + + Modal + + Close + + + + Modal Content + + + + ); +} +export default Example; +``` diff --git a/static/usage/v7/animations/group/vue.md b/static/usage/v7/animations/group/vue.md new file mode 100644 index 00000000000..82c05ba66e6 --- /dev/null +++ b/static/usage/v7/animations/group/vue.md @@ -0,0 +1,90 @@ +```html + + + +``` From 02a5381e373e04c5613ace982e124d2051ca8899 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 10 Jul 2023 12:35:28 -0400 Subject: [PATCH 02/13] us IDs --- static/usage/v7/animations/group/demo.html | 12 ++++++------ static/usage/v7/animations/group/javascript.md | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/static/usage/v7/animations/group/demo.html b/static/usage/v7/animations/group/demo.html index afc81b2df8d..0f556644a84 100644 --- a/static/usage/v7/animations/group/demo.html +++ b/static/usage/v7/animations/group/demo.html @@ -13,7 +13,7 @@ window.createAnimation = createAnimation; const squareA = createAnimation() - .addElement(document.querySelector('.card-a')) + .addElement(document.querySelector('#card-a')) .keyframes([ { offset: 0, transform: 'scale(1) rotate(0)' }, { offset: 0.5, transform: 'scale(1.5) rotate(45deg)' }, @@ -21,7 +21,7 @@ ]); const squareB = createAnimation() - .addElement(document.querySelector('.card-b')) + .addElement(document.querySelector('#card-b')) .keyframes([ { offset: 0, transform: 'scale(1)', opacity: '1' }, { offset: 0.5, transform: 'scale(1.5)', opacity: '0.3' }, @@ -29,7 +29,7 @@ ]); const squareC = createAnimation() - .addElement(document.querySelector('.card-c')) + .addElement(document.querySelector('#card-c')) .duration(5000) .keyframes([ { offset: 0, transform: 'scale(1)', opacity: '0.5' }, @@ -64,15 +64,15 @@
- + Card 1 - + Card 2 - + Card 2 diff --git a/static/usage/v7/animations/group/javascript.md b/static/usage/v7/animations/group/javascript.md index 6773c61c135..041fde996f1 100644 --- a/static/usage/v7/animations/group/javascript.md +++ b/static/usage/v7/animations/group/javascript.md @@ -1,13 +1,13 @@ ```html - + Card 1 - + Card 2 - + Card 2 @@ -17,7 +17,7 @@ ``` From bcb68cd6577dd1e689654b939144e5366a92c2a0 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 10 Jul 2023 12:55:31 -0400 Subject: [PATCH 04/13] add angular example --- .../group/angular/example_component_html.md | 36 ++++---- .../group/angular/example_component_ts.md | 84 +++++++++++-------- 2 files changed, 62 insertions(+), 58 deletions(-) diff --git a/static/usage/v7/animations/group/angular/example_component_html.md b/static/usage/v7/animations/group/angular/example_component_html.md index 178ae34c17b..81005d01806 100644 --- a/static/usage/v7/animations/group/angular/example_component_html.md +++ b/static/usage/v7/animations/group/angular/example_component_html.md @@ -1,23 +1,17 @@ ```html - - - Page - - - - Present Modal - - - - - Modal - - Close - - - - Modal Content - - - + + Card 1 + + + + Card 2 + + + + Card 2 + + +Play +Pause +Stop ``` diff --git a/static/usage/v7/animations/group/angular/example_component_ts.md b/static/usage/v7/animations/group/angular/example_component_ts.md index b1fe997c1d4..804dfef3d31 100644 --- a/static/usage/v7/animations/group/angular/example_component_ts.md +++ b/static/usage/v7/animations/group/angular/example_component_ts.md @@ -1,52 +1,62 @@ ```ts import { Component, ViewChild } from '@angular/core'; -import type { IonModal } from '@ionic/angular'; -import { AnimationController } from '@ionic/angular'; +import type { QueryList } from '@angular/core'; +import type { Animation } from '@ionic/angular'; +import { AnimationController, IonCard } from '@ionic/angular'; @Component({ selector: 'app-example', templateUrl: 'example.component.html', }) export class ExampleComponent { - @ViewChild('modal', { static: true }) modal: IonModal; + @ViewChildren(IonCard) cardElements: QueryList; + + private animation: Animation; constructor(private animationCtrl: AnimationController) {} - ngOnInit() { - const enterAnimation = (baseEl: HTMLElement) => { - const root = baseEl.shadowRoot; - - const backdropAnimation = this.animationCtrl - .create() - .addElement(root.querySelector('ion-backdrop')) - .fromTo('opacity', '0.01', 'var(--backdrop-opacity)'); - - const wrapperAnimation = this.animationCtrl - .create() - .addElement(root.querySelector('.modal-wrapper')) - .keyframes([ - { offset: 0, opacity: '0', transform: 'scale(0)' }, - { offset: 1, opacity: '0.99', transform: 'scale(1)' }, - ]); - - return this.animationCtrl - .create() - .addElement(baseEl) - .easing('ease-out') - .duration(500) - .addAnimation([backdropAnimation, wrapperAnimation]); - }; - - const leaveAnimation = (baseEl: HTMLElement) => { - return enterAnimation(baseEl).direction('reverse'); - }; - - this.modal.enterAnimation = enterAnimation; - this.modal.leaveAnimation = leaveAnimation; + ngAfterViewInit() { + const cardA = this.animationCtrl.create() + .addElement(this.cardElements.get(0).el) + .keyframes([ + { offset: 0, transform: 'scale(1) rotate(0)' }, + { offset: 0.5, transform: 'scale(1.5) rotate(45deg)' }, + { offset: 1, transform: 'scale(1) rotate(0) '} + ]); + + const cardB = this.animationCtrl.create() + .addElement(this.cardElements.get(1).el) + .keyframes([ + { offset: 0, transform: 'scale(1)', opacity: '1' }, + { offset: 0.5, transform: 'scale(1.5)', opacity: '0.3' }, + { offset: 1, transform: 'scale(1)', opacity: '1' } + ]); + + const cardC = this.animationCtrl.create() + .addElement(this.cardElements.get(2).el) + .duration(5000) + .keyframes([ + { offset: 0, transform: 'scale(1)', opacity: '0.5' }, + { offset: 0.5, transform: 'scale(0.5)', opacity: '1' }, + { offset: 1, transform: 'scale(1)', opacity: '0.5' } + ]); + + this.animation = this.animationCtrl.create() + .duration(2000) + .iterations(Infinity) + .addAnimation([cardA, cardB, cardC]); } - - closeModal() { - this.modal.dismiss(); + + play() { + this.animation.play(); + } + + pause() { + this.animation.pause(); + } + + stop() { + this.animation.stop(); } } ``` From 034e0b032921fb82fdb4fb02597d950ab13535cd Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 10 Jul 2023 12:55:45 -0400 Subject: [PATCH 05/13] typo --- .../usage/v7/animations/group/angular/example_component_ts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/usage/v7/animations/group/angular/example_component_ts.md b/static/usage/v7/animations/group/angular/example_component_ts.md index 804dfef3d31..970daccf49b 100644 --- a/static/usage/v7/animations/group/angular/example_component_ts.md +++ b/static/usage/v7/animations/group/angular/example_component_ts.md @@ -1,5 +1,5 @@ ```ts -import { Component, ViewChild } from '@angular/core'; +import { Component, ViewChildren } from '@angular/core'; import type { QueryList } from '@angular/core'; import type { Animation } from '@ionic/angular'; import { AnimationController, IonCard } from '@ionic/angular'; From c632748ff6df08c7d9de00d5c42d2294cb7c92bd Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 10 Jul 2023 12:56:16 -0400 Subject: [PATCH 06/13] another typo --- .../usage/v7/animations/group/angular/example_component_html.md | 2 +- static/usage/v7/animations/group/demo.html | 2 +- static/usage/v7/animations/group/javascript.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/static/usage/v7/animations/group/angular/example_component_html.md b/static/usage/v7/animations/group/angular/example_component_html.md index 81005d01806..bb61611b10c 100644 --- a/static/usage/v7/animations/group/angular/example_component_html.md +++ b/static/usage/v7/animations/group/angular/example_component_html.md @@ -8,7 +8,7 @@ - Card 2 + Card 3 Play diff --git a/static/usage/v7/animations/group/demo.html b/static/usage/v7/animations/group/demo.html index 85052caff8b..aa03ecf42ab 100644 --- a/static/usage/v7/animations/group/demo.html +++ b/static/usage/v7/animations/group/demo.html @@ -73,7 +73,7 @@ - Card 2 + Card 3
diff --git a/static/usage/v7/animations/group/javascript.md b/static/usage/v7/animations/group/javascript.md index c7b83f05555..2b7f838fd84 100644 --- a/static/usage/v7/animations/group/javascript.md +++ b/static/usage/v7/animations/group/javascript.md @@ -8,7 +8,7 @@ - Card 2 + Card 3 Play From 30c0c1b4d8f74d2f190d966800ffef3300357b43 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 10 Jul 2023 13:25:58 -0400 Subject: [PATCH 07/13] clean up angular example --- .../animations/group/angular/example_component_ts.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/static/usage/v7/animations/group/angular/example_component_ts.md b/static/usage/v7/animations/group/angular/example_component_ts.md index 970daccf49b..d4da3d2b244 100644 --- a/static/usage/v7/animations/group/angular/example_component_ts.md +++ b/static/usage/v7/animations/group/angular/example_component_ts.md @@ -1,5 +1,5 @@ ```ts -import { Component, ViewChildren } from '@angular/core'; +import { Component, ElementRef, ViewChildren } from '@angular/core'; import type { QueryList } from '@angular/core'; import type { Animation } from '@ionic/angular'; import { AnimationController, IonCard } from '@ionic/angular'; @@ -9,7 +9,7 @@ import { AnimationController, IonCard } from '@ionic/angular'; templateUrl: 'example.component.html', }) export class ExampleComponent { - @ViewChildren(IonCard) cardElements: QueryList; + @ViewChildren(IonCard, { read: ElementRef }) cardElements: QueryList>; private animation: Animation; @@ -17,7 +17,7 @@ export class ExampleComponent { ngAfterViewInit() { const cardA = this.animationCtrl.create() - .addElement(this.cardElements.get(0).el) + .addElement(this.cardElements.get(0).nativeElement) .keyframes([ { offset: 0, transform: 'scale(1) rotate(0)' }, { offset: 0.5, transform: 'scale(1.5) rotate(45deg)' }, @@ -25,7 +25,7 @@ export class ExampleComponent { ]); const cardB = this.animationCtrl.create() - .addElement(this.cardElements.get(1).el) + .addElement(this.cardElements.get(1).nativeElement) .keyframes([ { offset: 0, transform: 'scale(1)', opacity: '1' }, { offset: 0.5, transform: 'scale(1.5)', opacity: '0.3' }, @@ -33,7 +33,7 @@ export class ExampleComponent { ]); const cardC = this.animationCtrl.create() - .addElement(this.cardElements.get(2).el) + .addElement(this.cardElements.get(2).nativeElement) .duration(5000) .keyframes([ { offset: 0, transform: 'scale(1)', opacity: '0.5' }, From ec1c8e215bacc4e1709d7a37282a2549fd6add72 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 10 Jul 2023 15:16:42 -0400 Subject: [PATCH 08/13] add vue demo --- static/usage/v7/animations/group/vue.md | 125 ++++++++++++------------ 1 file changed, 63 insertions(+), 62 deletions(-) diff --git a/static/usage/v7/animations/group/vue.md b/static/usage/v7/animations/group/vue.md index 82c05ba66e6..9625fa76395 100644 --- a/static/usage/v7/animations/group/vue.md +++ b/static/usage/v7/animations/group/vue.md @@ -1,88 +1,89 @@ ```html ``` diff --git a/static/usage/v7/animations/group/react.md b/static/usage/v7/animations/group/react.md index 29b5a5d084a..23b00bbee74 100644 --- a/static/usage/v7/animations/group/react.md +++ b/static/usage/v7/animations/group/react.md @@ -1,11 +1,6 @@ ```tsx import React, { useEffect, useRef } from 'react'; -import { - IonButton, - IonCard, - IonCardContent, - createAnimation, -} from '@ionic/react'; +import { IonButton, IonCard, IonCardContent, createAnimation } from '@ionic/react'; import type { Animation } from '@ionic/react'; function Example() { @@ -14,7 +9,7 @@ function Example() { const cardCEl = useRef(null); const animation = useRef(null); - + useEffect(() => { if (animation.current === null) { const cardA = createAnimation() @@ -22,54 +17,63 @@ function Example() { .keyframes([ { offset: 0, transform: 'scale(1) rotate(0)' }, { offset: 0.5, transform: 'scale(1.5) rotate(45deg)' }, - { offset: 1, transform: 'scale(1) rotate(0) '} + { offset: 1, transform: 'scale(1) rotate(0) ' }, ]); - + const cardB = createAnimation() .addElement(cardBEl.current!) .keyframes([ { offset: 0, transform: 'scale(1)', opacity: '1' }, { offset: 0.5, transform: 'scale(1.5)', opacity: '0.3' }, - { offset: 1, transform: 'scale(1)', opacity: '1' } + { offset: 1, transform: 'scale(1)', opacity: '1' }, ]); - + const cardC = createAnimation() .addElement(cardCEl.current!) .duration(5000) .keyframes([ { offset: 0, transform: 'scale(1)', opacity: '0.5' }, { offset: 0.5, transform: 'scale(0.5)', opacity: '1' }, - { offset: 1, transform: 'scale(1)', opacity: '0.5' } + { offset: 1, transform: 'scale(1)', opacity: '0.5' }, ]); - - animation.current = createAnimation() - .duration(2000) - .iterations(Infinity) - .addAnimation([cardA, cardB, cardC]) + + animation.current = createAnimation().duration(2000).iterations(Infinity).addAnimation([cardA, cardB, cardC]); } }, [cardAEl, cardBEl, cardCEl]); - - const play = () => { animation.current?.play(); }; - const pause = () => { animation.current?.pause(); }; - const stop = () => { animation.current?.stop(); }; + + const play = () => { + animation.current?.play(); + }; + const pause = () => { + animation.current?.pause(); + }; + const stop = () => { + animation.current?.stop(); + }; return ( <> Card 1 - + Card 2 - + Card 3 - - Play - Pause - Stop + + + Play + + + Pause + + + Stop + ); } diff --git a/static/usage/v7/animations/group/vue.md b/static/usage/v7/animations/group/vue.md index 5a9ce97b493..4302f414bb6 100644 --- a/static/usage/v7/animations/group/vue.md +++ b/static/usage/v7/animations/group/vue.md @@ -3,27 +3,22 @@ Card 1 - + Card 2 - + Card 3 - + Play Pause Stop