docs(animations): use our heroes
@ -29,7 +29,7 @@ describe('Animation Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('animates between active and inactive', () => {
|
it('animates between active and inactive', () => {
|
||||||
addHero();
|
addInactiveHero();
|
||||||
|
|
||||||
let li = host.element(by.css('li'));
|
let li = host.element(by.css('li'));
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ describe('Animation Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('are not kept after animation', () => {
|
it('are not kept after animation', () => {
|
||||||
addHero();
|
addInactiveHero();
|
||||||
|
|
||||||
let li = host.element(by.css('li'));
|
let li = host.element(by.css('li'));
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ describe('Animation Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('animates between active and inactive', () => {
|
it('animates between active and inactive', () => {
|
||||||
addHero();
|
addInactiveHero();
|
||||||
|
|
||||||
let li = host.element(by.css('li'));
|
let li = host.element(by.css('li'));
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ describe('Animation Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('animates between active and inactive', () => {
|
it('animates between active and inactive', () => {
|
||||||
addHero();
|
addInactiveHero();
|
||||||
|
|
||||||
let li = host.element(by.css('li'));
|
let li = host.element(by.css('li'));
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ describe('Animation Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds and removes element', () => {
|
it('adds and removes element', () => {
|
||||||
addHero();
|
addInactiveHero();
|
||||||
|
|
||||||
let li = host.element(by.css('li'));
|
let li = host.element(by.css('li'));
|
||||||
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
|
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
|
||||||
@ -157,7 +157,7 @@ describe('Animation Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds and removes and animates between active and inactive', () => {
|
it('adds and removes and animates between active and inactive', () => {
|
||||||
addHero();
|
addInactiveHero();
|
||||||
|
|
||||||
let li = host.element(by.css('li'));
|
let li = host.element(by.css('li'));
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ describe('Animation Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds and removes element', () => {
|
it('adds and removes element', () => {
|
||||||
addHero();
|
addInactiveHero();
|
||||||
|
|
||||||
let li = host.element(by.css('li'));
|
let li = host.element(by.css('li'));
|
||||||
expect(li.getCssValue('height')).toBe('50px');
|
expect(li.getCssValue('height')).toBe('50px');
|
||||||
@ -206,7 +206,7 @@ describe('Animation Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds and removes element', () => {
|
it('adds and removes element', () => {
|
||||||
addHero();
|
addInactiveHero();
|
||||||
|
|
||||||
let li = host.element(by.css('li'));
|
let li = host.element(by.css('li'));
|
||||||
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
|
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
|
||||||
@ -227,7 +227,7 @@ describe('Animation Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds and removes element', () => {
|
it('adds and removes element', () => {
|
||||||
addHero();
|
addInactiveHero();
|
||||||
|
|
||||||
let li = host.element(by.css('li'));
|
let li = host.element(by.css('li'));
|
||||||
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
|
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
|
||||||
@ -248,7 +248,7 @@ describe('Animation Tests', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('adds and removes element', () => {
|
it('adds and removes element', () => {
|
||||||
addHero();
|
addInactiveHero();
|
||||||
|
|
||||||
let li = host.element(by.css('li'));
|
let li = host.element(by.css('li'));
|
||||||
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
|
expect(li.getCssValue('transform')).toMatch(NO_TRANSFORM_MATRIX_REGEX);
|
||||||
@ -260,8 +260,41 @@ describe('Animation Tests', () => {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function addHero() {
|
describe('adding active heroes', () => {
|
||||||
element(by.buttonText('Add hero')).click();
|
|
||||||
|
let host: protractor.ElementFinder;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
host = element(by.css('hero-list-basic'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('animates between active and inactive', () => {
|
||||||
|
addActiveHero();
|
||||||
|
|
||||||
|
let li = host.element(by.css('li'));
|
||||||
|
|
||||||
|
expect(getScaleX(li)).toBe(1.1);
|
||||||
|
expect(li.getCssValue('backgroundColor')).toBe(ACTIVE_COLOR);
|
||||||
|
|
||||||
|
li.click();
|
||||||
|
browser.driver.sleep(300);
|
||||||
|
expect(getScaleX(li)).toBe(1.0);
|
||||||
|
expect(li.getCssValue('backgroundColor')).toBe(INACTIVE_COLOR);
|
||||||
|
|
||||||
|
li.click();
|
||||||
|
browser.driver.sleep(300);
|
||||||
|
expect(getScaleX(li)).toBe(1.1);
|
||||||
|
expect(li.getCssValue('backgroundColor')).toBe(ACTIVE_COLOR);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function addActiveHero() {
|
||||||
|
element(by.buttonText('Add active hero')).click();
|
||||||
|
browser.driver.sleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addInactiveHero() {
|
||||||
|
element(by.buttonText('Add inactive hero')).click();
|
||||||
browser.driver.sleep(500);
|
browser.driver.sleep(500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,8 @@ import { HeroListTimingsComponent } from './hero-list-timings.component';
|
|||||||
selector: 'hero-team-builder',
|
selector: 'hero-team-builder',
|
||||||
template: `
|
template: `
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button [disabled]="!heroes.canAdd()" (click)="heroes.add()">Add hero</button>
|
<button [disabled]="!heroes.canAdd()" (click)="heroes.addInactive()">Add inactive hero</button>
|
||||||
|
<button [disabled]="!heroes.canAdd()" (click)="heroes.addActive()">Add active hero</button>
|
||||||
<button [disabled]="!heroes.canRemove()" (click)="heroes.remove()">Remove hero</button>
|
<button [disabled]="!heroes.canRemove()" (click)="heroes.remove()">Remove hero</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
|
@ -11,19 +11,17 @@ class Hero {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let ALL_HEROES = [
|
let ALL_HEROES = [
|
||||||
'Wolverine',
|
'Windstorm',
|
||||||
'Magneto',
|
'RubberMan',
|
||||||
'Emma Frost',
|
'Bombasto',
|
||||||
'Thing',
|
'Magneta',
|
||||||
'Kitty Pryde',
|
'Dynama',
|
||||||
'Nightcrawler',
|
'Narco',
|
||||||
'Juggernaut',
|
'Celeritas',
|
||||||
'Beast',
|
'Dr IQ',
|
||||||
'Captain America',
|
'Magma',
|
||||||
'Spider-Man',
|
'Tornado',
|
||||||
'Puck',
|
'Mr. Nice'
|
||||||
'Alex Wilder',
|
|
||||||
'Doctor Strange'
|
|
||||||
].map(name => new Hero(name));
|
].map(name => new Hero(name));
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -43,8 +41,16 @@ export class Heroes implements Iterable<Hero> {
|
|||||||
return this.currentHeroes.length > 0;
|
return this.currentHeroes.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
add() {
|
addActive() {
|
||||||
this.currentHeroes.push(ALL_HEROES[this.currentHeroes.length]);
|
let hero = ALL_HEROES[this.currentHeroes.length];
|
||||||
|
hero.state = 'active';
|
||||||
|
this.currentHeroes.push(hero);
|
||||||
|
}
|
||||||
|
|
||||||
|
addInactive() {
|
||||||
|
let hero = ALL_HEROES[this.currentHeroes.length];
|
||||||
|
hero.state = 'inactive';
|
||||||
|
this.currentHeroes.push(hero);
|
||||||
}
|
}
|
||||||
|
|
||||||
remove() {
|
remove() {
|
||||||
|
Before Width: | Height: | Size: 224 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 221 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 805 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 242 KiB After Width: | Height: | Size: 71 KiB |
Before Width: | Height: | Size: 304 KiB After Width: | Height: | Size: 44 KiB |
Before Width: | Height: | Size: 225 KiB After Width: | Height: | Size: 79 KiB |