Skip to content

Commit e3aeb5f

Browse files
committed
Initial commit
1 parent cf94c94 commit e3aeb5f

12 files changed

+74
-23
lines changed

.angular-cli.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"testTsconfig": "tsconfig.spec.json",
2020
"prefix": "app",
2121
"styles": [
22-
"styles.css"
22+
"styles.scss"
2323
],
2424
"scripts": [],
2525
"environmentSource": "environments/environment.ts",
@@ -54,7 +54,7 @@
5454
}
5555
},
5656
"defaults": {
57-
"styleExt": "css",
57+
"styleExt": "scss",
5858
"component": {}
5959
}
6060
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@angular/router": "^5.0.0",
2424
"core-js": "^2.4.1",
2525
"rxjs": "^5.5.2",
26+
"web-animations-js": "^2.3.1",
2627
"zone.js": "^0.8.14"
2728
},
2829
"devDependencies": {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { trigger, state, style, transition, animate, keyframes } from '@angular/animations';
2+
3+
export const ROTATE_TEXT_ANIMATION =
4+
trigger('rotateText', [
5+
state('zero', style({
6+
transform: 'rotate(0deg)',
7+
})),
8+
state('rotated', style({
9+
transform: 'rotate(-180deg)',
10+
})),
11+
transition('zero <=> rotated',
12+
animate('500ms ease-in-out')),
13+
]);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p [@rotateText]='state' (click)="rotateMe()">Rotation works!!!</p>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
p {
2+
width:200px;
3+
background:lightgray;
4+
margin: 100px auto;
5+
text-align:center;
6+
padding:20px;
7+
font-size:1.5em;
8+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
import { ROTATE_TEXT_ANIMATION } from './ROTATE_TEXT_ANIMATION';
4+
5+
6+
@Component({
7+
selector: 'app-animation',
8+
templateUrl: 'animation.component.html',
9+
styleUrls: ['animation.component.scss'],
10+
animations: [ROTATE_TEXT_ANIMATION]
11+
})
12+
13+
export class AnimationComponent implements OnInit {
14+
15+
state: String = 'zero';
16+
17+
constructor() { }
18+
19+
ngOnInit() { }
20+
21+
rotateMe() {
22+
this.state = (this.state === 'zero' ? 'rotated' : 'zero');
23+
}
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { NgModule } from '@angular/core';
2+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
3+
import { CommonModule } from '@angular/common';
4+
5+
import { AnimationComponent } from './animation.component';
6+
7+
@NgModule({
8+
imports: [
9+
CommonModule,
10+
BrowserAnimationsModule
11+
],
12+
exports: [AnimationComponent],
13+
declarations: [AnimationComponent],
14+
providers: [],
15+
})
16+
export class AnimationModule { }

src/app/app.component.html

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,2 @@
11
<!--The content below is only a placeholder and can be replaced.-->
2-
<div style="text-align:center">
3-
<h1>
4-
Welcome to {{ title }}!
5-
</h1>
6-
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
7-
</div>
8-
<h2>Here are some links to help you start: </h2>
9-
<ul>
10-
<li>
11-
<h2><a target="_blank" rel="noopener" href="https://angular.io/tutorial">Tour of Heroes</a></h2>
12-
</li>
13-
<li>
14-
<h2><a target="_blank" rel="noopener" href="https://github.com/angular/angular-cli/wiki">CLI Documentation</a></h2>
15-
</li>
16-
<li>
17-
<h2><a target="_blank" rel="noopener" href="https://blog.angular.io/">Angular blog</a></h2>
18-
</li>
19-
</ul>
20-
2+
<app-animation></app-animation>

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { BrowserModule } from '@angular/platform-browser';
22
import { NgModule } from '@angular/core';
3+
import { AnimationModule } from './animations/animation.module';
34

45

56
import { AppComponent } from './app.component';
@@ -10,7 +11,8 @@ import { AppComponent } from './app.component';
1011
AppComponent
1112
],
1213
imports: [
13-
BrowserModule
14+
BrowserModule,
15+
AnimationModule
1416
],
1517
providers: [],
1618
bootstrap: [AppComponent]

src/polyfills.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import 'core-js/es7/reflect';
5050
* Required to support Web Animations `@angular/platform-browser/animations`.
5151
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
5252
**/
53-
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
53+
import 'web-animations-js'; // Run `npm install --save web-animations-js`.
5454

5555

5656

0 commit comments

Comments
 (0)