Skip to content

Commit 45c0926

Browse files
committed
A couple more updates for the animation demo
1 parent a55319c commit 45c0926

File tree

4 files changed

+70
-7
lines changed

4 files changed

+70
-7
lines changed

angular2-animated-notifications-panel/app/notification/notification.component.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
justify-content: center;
66
min-height: 0;
77
min-width: 0;
8+
max-height: 48px;
89
padding: 8px;
910
}
1011

angular2-animated-notifications-panel/app/notification/notification.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
<div class="icon" [ngSwitch]="notification.type">
1+
<div class="icon" @iconTrigger="expandedState" [ngSwitch]="notification.type">
22
<i *ngSwitchCase="0" class="fa fa-comment"></i>
33
<i *ngSwitchCase="1" class="fa fa-exclamation-triangle"></i>
44
<i *ngSwitchCase="2" class="fa fa-code"></i>
55
<i *ngSwitchCase="3" class="fa fa-credit-card"></i>
66
</div>
7-
<div *ngIf="expanded" class="details">
7+
<div *ngIf="expanded" @detailsTrigger="'in'" class="details">
88
<div class="message">
99
<span>{{notification.message}}</span>
1010
</div>

angular2-animated-notifications-panel/app/notification/notification.component.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ var index_1 = require("../shared/index");
1313
var NotificationComponent = (function () {
1414
function NotificationComponent() {
1515
this.remove = new core_1.EventEmitter(false);
16+
this.expandedState = 'collapsed';
1617
this.notificationTypes = index_1.NotificationType;
1718
}
1819
NotificationComponent.prototype.ngOnInit = function () { };
20+
NotificationComponent.prototype.ngOnChanges = function (changes) {
21+
if (changes["expanded"] !== undefined) {
22+
this.expandedState = this.expanded ? 'expanded' : 'collapsed';
23+
}
24+
};
1925
__decorate([
2026
core_1.Input(),
2127
__metadata('design:type', index_1.Notification)
@@ -33,7 +39,25 @@ var NotificationComponent = (function () {
3339
moduleId: module.id,
3440
selector: 'notification',
3541
templateUrl: 'notification.component.html',
36-
styleUrls: ['notification.component.css']
42+
styleUrls: ['notification.component.css'],
43+
animations: [
44+
core_1.trigger('detailsTrigger', [
45+
core_1.state('in', core_1.style({ opacity: '1' })),
46+
core_1.transition('void => *', [
47+
core_1.style({ opacity: '0' }),
48+
core_1.animate('200ms 300ms')
49+
]),
50+
core_1.transition('* => void', [
51+
core_1.animate('200ms', core_1.style({ opacity: '0' }))
52+
])
53+
]),
54+
core_1.trigger('iconTrigger', [
55+
core_1.state('collapsed', core_1.style({ fontSize: '1.0em' })),
56+
core_1.state('expanded', core_1.style({ fontSize: '1.5em' })),
57+
core_1.transition('collapsed => expanded', core_1.animate('200ms ease-in')),
58+
core_1.transition('expanded => collapsed', core_1.animate('200ms ease-out'))
59+
])
60+
]
3761
}),
3862
__metadata('design:paramtypes', [])
3963
], NotificationComponent);
Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,60 @@
1-
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
1+
import {
2+
Component,
3+
OnInit,
4+
OnChanges,
5+
SimpleChanges,
6+
Input,
7+
Output,
8+
EventEmitter,
9+
trigger,
10+
state,
11+
style,
12+
transition,
13+
animate
14+
} from '@angular/core';
215

316
import {Notification, NotificationType} from "../shared/index";
417

518
@Component({
619
moduleId: module.id,
720
selector: 'notification',
821
templateUrl: 'notification.component.html',
9-
styleUrls: ['notification.component.css']
22+
styleUrls: ['notification.component.css'],
23+
animations: [
24+
trigger('detailsTrigger', [
25+
state('in', style({ opacity: '1' })),
26+
transition('void => *', [
27+
style({ opacity: '0' }),
28+
animate('200ms 300ms')
29+
]),
30+
transition('* => void', [
31+
animate('200ms', style({ opacity: '0' }))
32+
])
33+
]),
34+
trigger('iconTrigger', [
35+
state('collapsed', style({ fontSize: '1.0em' })),
36+
state('expanded', style({ fontSize: '1.5em' })),
37+
transition('collapsed => expanded', animate('200ms ease-in')),
38+
transition('expanded => collapsed', animate('200ms ease-out'))
39+
])
40+
]
1041
})
11-
export class NotificationComponent implements OnInit {
42+
export class NotificationComponent implements OnInit, OnChanges {
1243
@Input() notification: Notification;
1344
@Input() expanded: boolean;
1445
@Output() remove = new EventEmitter<any>(false);
1546

47+
expandedState = 'collapsed';
48+
1649
notificationTypes = NotificationType;
17-
50+
1851
constructor() { }
1952

2053
ngOnInit() { }
2154

55+
ngOnChanges(changes: SimpleChanges) {
56+
if (changes["expanded"] !== undefined) {
57+
this.expandedState = this.expanded ? 'expanded' : 'collapsed';
58+
}
59+
}
2260
}

0 commit comments

Comments
 (0)