Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit 3b4b79a

Browse files
committed
docs(animations): use our heroes
1 parent 30609c8 commit 3b4b79a

File tree

10 files changed

+68
-28
lines changed

10 files changed

+68
-28
lines changed

public/docs/_examples/animations/e2e-spec.ts

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Animation Tests', () => {
2929
});
3030

3131
it('animates between active and inactive', () => {
32-
addHero();
32+
addInactiveHero();
3333

3434
let li = host.element(by.css('li'));
3535

@@ -58,7 +58,7 @@ describe('Animation Tests', () => {
5858
});
5959

6060
it('are not kept after animation', () => {
61-
addHero();
61+
addInactiveHero();
6262

6363
let li = host.element(by.css('li'));
6464

@@ -79,7 +79,7 @@ describe('Animation Tests', () => {
7979
});
8080

8181
it('animates between active and inactive', () => {
82-
addHero();
82+
addInactiveHero();
8383

8484
let li = host.element(by.css('li'));
8585

@@ -108,7 +108,7 @@ describe('Animation Tests', () => {
108108
});
109109

110110
it('animates between active and inactive', () => {
111-
addHero();
111+
addInactiveHero();
112112

113113
let li = host.element(by.css('li'));
114114

@@ -137,7 +137,7 @@ describe('Animation Tests', () => {
137137
});
138138

139139
it('adds and removes element', () => {
140-
addHero();
140+
addInactiveHero();
141141

142142
let li = host.element(by.css('li'));
143143
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
@@ -157,7 +157,7 @@ describe('Animation Tests', () => {
157157
});
158158

159159
it('adds and removes and animates between active and inactive', () => {
160-
addHero();
160+
addInactiveHero();
161161

162162
let li = host.element(by.css('li'));
163163

@@ -186,7 +186,7 @@ describe('Animation Tests', () => {
186186
});
187187

188188
it('adds and removes element', () => {
189-
addHero();
189+
addInactiveHero();
190190

191191
let li = host.element(by.css('li'));
192192
expect(li.getCssValue('height')).toBe('50px');
@@ -206,7 +206,7 @@ describe('Animation Tests', () => {
206206
});
207207

208208
it('adds and removes element', () => {
209-
addHero();
209+
addInactiveHero();
210210

211211
let li = host.element(by.css('li'));
212212
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
@@ -227,7 +227,7 @@ describe('Animation Tests', () => {
227227
});
228228

229229
it('adds and removes element', () => {
230-
addHero();
230+
addInactiveHero();
231231

232232
let li = host.element(by.css('li'));
233233
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
@@ -248,7 +248,7 @@ describe('Animation Tests', () => {
248248
});
249249

250250
it('adds and removes element', () => {
251-
addHero();
251+
addInactiveHero();
252252

253253
let li = host.element(by.css('li'));
254254
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
@@ -260,8 +260,41 @@ describe('Animation Tests', () => {
260260

261261
});
262262

263-
function addHero() {
264-
element(by.buttonText('Add hero')).click();
263+
describe('adding active heroes', () => {
264+
265+
let host: protractor.ElementFinder;
266+
267+
beforeEach(() => {
268+
host = element(by.css('hero-list-basic'));
269+
});
270+
271+
it('animates between active and inactive', () => {
272+
addActiveHero();
273+
274+
let li = host.element(by.css('li'));
275+
276+
expect(getScaleX(li)).toBe(1.1);
277+
expect(li.getCssValue('backgroundColor')).toBe(ACTIVE_COLOR);
278+
279+
li.click();
280+
browser.driver.sleep(300);
281+
expect(getScaleX(li)).toBe(1.0);
282+
expect(li.getCssValue('backgroundColor')).toBe(INACTIVE_COLOR);
283+
284+
li.click();
285+
browser.driver.sleep(300);
286+
expect(getScaleX(li)).toBe(1.1);
287+
expect(li.getCssValue('backgroundColor')).toBe(ACTIVE_COLOR);
288+
});
289+
});
290+
291+
function addActiveHero() {
292+
element(by.buttonText('Add active hero')).click();
293+
browser.driver.sleep(500);
294+
}
295+
296+
function addInactiveHero() {
297+
element(by.buttonText('Add inactive hero')).click();
265298
browser.driver.sleep(500);
266299
}
267300

public/docs/_examples/animations/ts/app/hero-team-builder.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import { HeroListTimingsComponent } from './hero-list-timings.component';
1616
selector: 'hero-team-builder',
1717
template: `
1818
<div class="buttons">
19-
<button [disabled]="!heroes.canAdd()" (click)="heroes.add()">Add hero</button>
19+
<button [disabled]="!heroes.canAdd()" (click)="heroes.addInactive()">Add inactive hero</button>
20+
<button [disabled]="!heroes.canAdd()" (click)="heroes.addActive()">Add active hero</button>
2021
<button [disabled]="!heroes.canRemove()" (click)="heroes.remove()">Remove hero</button>
2122
</div>
2223
<div class="columns">

public/docs/_examples/animations/ts/app/hero.service.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,17 @@ class Hero {
1111
}
1212

1313
let ALL_HEROES = [
14-
'Wolverine',
15-
'Magneto',
16-
'Emma Frost',
17-
'Thing',
18-
'Kitty Pryde',
19-
'Nightcrawler',
20-
'Juggernaut',
21-
'Beast',
22-
'Captain America',
23-
'Spider-Man',
24-
'Puck',
25-
'Alex Wilder',
26-
'Doctor Strange'
14+
'Windstorm',
15+
'RubberMan',
16+
'Bombasto',
17+
'Magneta',
18+
'Dynama',
19+
'Narco',
20+
'Celeritas',
21+
'Dr IQ',
22+
'Magma',
23+
'Tornado',
24+
'Mr. Nice'
2725
].map(name => new Hero(name));
2826

2927
@Injectable()
@@ -43,8 +41,16 @@ export class Heroes implements Iterable<Hero> {
4341
return this.currentHeroes.length > 0;
4442
}
4543

46-
add() {
47-
this.currentHeroes.push(ALL_HEROES[this.currentHeroes.length]);
44+
addActive() {
45+
let hero = ALL_HEROES[this.currentHeroes.length];
46+
hero.state = 'active';
47+
this.currentHeroes.push(hero);
48+
}
49+
50+
addInactive() {
51+
let hero = ALL_HEROES[this.currentHeroes.length];
52+
hero.state = 'inactive';
53+
this.currentHeroes.push(hero);
4854
}
4955

5056
remove() {
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)