-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(animation): add playground for group example (#3025)
- Loading branch information
1 parent
15817f4
commit 2c7303e
Showing
8 changed files
with
408 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
static/usage/v7/animations/group/angular/example_component_html.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
```html | ||
<ion-card> | ||
<ion-card-content>Card 1</ion-card-content> | ||
</ion-card> | ||
|
||
<ion-card> | ||
<ion-card-content>Card 2</ion-card-content> | ||
</ion-card> | ||
|
||
<ion-card> | ||
<ion-card-content>Card 3</ion-card-content> | ||
</ion-card> | ||
|
||
<ion-button id="play" (click)="play()">Play</ion-button> | ||
<ion-button id="pause" (click)="pause()">Pause</ion-button> | ||
<ion-button id="stop" (click)="stop()">Stop</ion-button> | ||
``` |
66 changes: 66 additions & 0 deletions
66
static/usage/v7/animations/group/angular/example_component_ts.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
```ts | ||
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'; | ||
|
||
@Component({ | ||
selector: 'app-example', | ||
templateUrl: 'example.component.html', | ||
}) | ||
export class ExampleComponent { | ||
@ViewChildren(IonCard, { read: ElementRef }) cardElements: QueryList<ElementRef<HTMLIonCardElement>>; | ||
|
||
private animation: Animation; | ||
|
||
constructor(private animationCtrl: AnimationController) {} | ||
|
||
ngAfterViewInit() { | ||
const cardA = this.animationCtrl | ||
.create() | ||
.addElement(this.cardElements.get(0).nativeElement) | ||
.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).nativeElement) | ||
.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).nativeElement) | ||
.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]); | ||
} | ||
|
||
play() { | ||
this.animation.play(); | ||
} | ||
|
||
pause() { | ||
this.animation.pause(); | ||
} | ||
|
||
stop() { | ||
this.animation.stop(); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Animation</title> | ||
<link rel="stylesheet" href="../../../common.css" /> | ||
<script src="../../../common.js"></script> | ||
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core@7/dist/ionic/ionic.esm.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@ionic/core@7/css/ionic.bundle.css" /> | ||
<script type="module"> | ||
import { createAnimation } from 'https://cdn.jsdelivr.net/npm/@ionic/core@7/dist/ionic/index.esm.js'; | ||
window.createAnimation = createAnimation; | ||
|
||
const cardA = createAnimation() | ||
.addElement(document.querySelector('#card-a')) | ||
.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 = createAnimation() | ||
.addElement(document.querySelector('#card-b')) | ||
.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 = createAnimation() | ||
.addElement(document.querySelector('#card-c')) | ||
.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' }, | ||
]); | ||
|
||
const animation = createAnimation().duration(2000).iterations(Infinity).addAnimation([cardA, cardB, cardC]); | ||
|
||
document.querySelector('#play').addEventListener('click', () => { | ||
animation.play(); | ||
}); | ||
|
||
document.querySelector('#pause').addEventListener('click', () => { | ||
animation.pause(); | ||
}); | ||
|
||
document.querySelector('#stop').addEventListener('click', () => { | ||
animation.stop(); | ||
}); | ||
</script> | ||
|
||
<style> | ||
.container { | ||
flex-direction: column; | ||
} | ||
|
||
ion-card { | ||
width: 70%; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<ion-card id="card-a"> | ||
<ion-card-content>Card 1</ion-card-content> | ||
</ion-card> | ||
|
||
<ion-card id="card-b"> | ||
<ion-card-content>Card 2</ion-card-content> | ||
</ion-card> | ||
|
||
<ion-card id="card-c"> | ||
<ion-card-content>Card 3</ion-card-content> | ||
</ion-card> | ||
|
||
<div> | ||
<ion-button id="play">Play</ion-button> | ||
<ion-button id="pause">Pause</ion-button> | ||
<ion-button id="stop">Stop</ion-button> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.
2c7303e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ionic-docs – ./
ionic-docs-ionic1.vercel.app
ionic-docs-git-main-ionic1.vercel.app
ionic-docs-gqykycf8t.vercel.app