Skip to content

Commit 5d27fcc

Browse files
committed
Updated
1 parent 054737a commit 5d27fcc

3 files changed

Lines changed: 91 additions & 8 deletions

File tree

src/assets/img/mobile.png

1.52 KB
Loading

src/pages/home/home.html

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,38 @@
11
<ion-header>
22
<ion-navbar>
33
<ion-title>
4-
Ionic Blank
4+
Ionic Angular4 Animations
55
</ion-title>
66
</ion-navbar>
77
</ion-header>
88

99
<ion-content padding [@colorChange]="currentColor">
10-
<button ion-button (click)="changeColor()">Change background color</button>
11-
<button ion-button (click)="changeSize()" [@sizeChange]='currentSize'>Change button size</button>
10+
11+
<ion-list no-lines>
12+
<ion-item-divider color="light">Animation Background Color</ion-item-divider>
13+
<ion-item>
14+
<button ion-button (click)="changeColor()">Test</button>
15+
</ion-item>
16+
<!--
17+
<ion-item-divider color="light">Change Button Size</ion-item-divider>
18+
<ion-item>
19+
<button ion-button (click)="changeSize()" [@sizeChange]='currentSize'>Test</button>
20+
</ion-item>
21+
-->
22+
<ion-item-divider color="light">Animation Resize Button</ion-item-divider>
23+
<ion-item>
24+
<button ion-button (click)="resizeButton()" [@resize]='resize'>Test</button>
25+
</ion-item>
26+
<ion-item-divider color="light">Animation Shake Mobile Icon</ion-item-divider>
27+
<ion-item>
28+
<button ion-button (click)="shakeIcon()">Test</button>
29+
<img src="assets/img/mobile.png" [@shake]='shake'>
30+
</ion-item>
31+
</ion-list>
32+
33+
<!--
34+
<ion-row>
35+
<img src="assets/img/mobile.png" [@scale]='scale'>
36+
</ion-row>
37+
-->
1238
</ion-content>

src/pages/home/home.ts

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component } from '@angular/core';
2-
import { animate, state, style, transition, trigger } from '@angular/animations';
2+
import { animate, state, style, transition, trigger, keyframes } from '@angular/animations';
33
import { NavController } from 'ionic-angular';
44

55
@Component({
@@ -26,17 +26,57 @@ import { NavController } from 'ionic-angular';
2626
state('pink', style({ background: 'pink' })),
2727
transition('* => pink', animate('3000ms'))
2828
]),
29+
/*
2930
trigger('sizeChange', [
3031
state('small', style({
3132
transform: 'scale(1)',
3233
})),
3334
state('large', style({
3435
transform: 'scale(1.2)',
3536
})),
36-
transition('small <=> large', animate('300ms ease-in', style({
37-
transform: 'translateY(40px)'
38-
}))),
37+
transition('small <=> large', animate('300ms ease-in', keyframes([
38+
style({opacity: 0, transform: 'translateY(-75%)', offset: 0}),
39+
style({opacity: 1, transform: 'translateY(35px)', offset: 0.5}),
40+
style({opacity: 1, transform: 'translateY(0)', offset: 1.0})
41+
]))),
3942
]),
43+
*/
44+
trigger('resize', [
45+
state('small', style({
46+
transform: 'scale(1)',
47+
})),
48+
state('large', style({
49+
transform: 'scale(1.3)',
50+
})),
51+
transition('small <=> large', animate('300ms ease-in-out')),
52+
]),
53+
trigger('shake', [
54+
state('start', style ({
55+
perspective: '1000px'
56+
})),
57+
state('end', style ({
58+
perspective: '1000px'
59+
})),
60+
transition('start <=> end', animate('5s cubic-bezier(.36,.07,.19,.97)', keyframes([
61+
style({transform: 'translate3d(-1px, 0, 0)', offset: 0.1}),
62+
style({transform: 'translate3d(2px, 0, 0)', offset: 0.2}),
63+
style({transform: 'translate3d(-4px, 0, 0)', offset: 0.3}),
64+
style({transform: 'translate3d(4px, 0, 0)', offset: 0.4}),
65+
style({transform: 'translate3d(-4px, 0, 0)', offset: 0.5}),
66+
style({transform: 'translate3d(4px, 0, 0)', offset: 0.6}),
67+
style({transform: 'translate3d(-4px, 0, 0)', offset: 0.7}),
68+
style({transform: 'translate3d(2px, 0, 0)', offset: 0.8}),
69+
style({transform: 'translate3d(-1px, 0, 0)', offset: 0.9}),
70+
])))
71+
]),
72+
/*
73+
trigger('scale', [
74+
transition('* <=> *', animate('1s ease-in-out', keyframes([
75+
style({ transform: 'scale(0.5)' }),
76+
style({ transform: 'scale(1)' })
77+
])))
78+
])
79+
*/
4080
],
4181
})
4282
export class HomePage {
@@ -45,7 +85,13 @@ export class HomePage {
4585
private currentColor: string;
4686
colorArr: string[] = ['red', 'green', 'blue', 'yellow', 'orange', 'aqua', 'pink', 'white'];
4787

48-
private currentSize: string = 'small';
88+
//private currentSize: string = 'small';
89+
90+
private shake: string = 'start';
91+
92+
private resize: string = 'small';
93+
94+
//private scale: string = 'scale';
4995

5096
constructor(public navCtrl: NavController) {
5197

@@ -62,8 +108,19 @@ export class HomePage {
62108
}
63109
}
64110

111+
/*
65112
changeSize() {
66113
this.currentSize = (this.currentSize === 'small' ? 'large' : 'small');
67114
}
115+
*/
116+
117+
resizeButton() {
118+
this.resize = (this.resize === 'small' ? 'large' : 'small');
119+
}
120+
121+
shakeIcon() {
122+
console.log("shakeIcon");
123+
this.shake = (this.shake === 'start' ? 'end' : 'start');
124+
}
68125

69126
}

0 commit comments

Comments
 (0)