refactor(animations): single animation engine code pass
This commit is contained in:

committed by
Jason Aden

parent
16c8167886
commit
8a6eb1ac78
@ -35,11 +35,6 @@ export class BrowserAnimationBuilder extends AnimationBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class NoopAnimationBuilder extends BrowserAnimationBuilder {
|
||||
build(animation: AnimationMetadata|AnimationMetadata[]): Animation { return new NoopAnimation(); }
|
||||
}
|
||||
|
||||
export class BrowserAnimation extends Animation {
|
||||
constructor(private _id: string, private _renderer: AnimationRenderer) { super(); }
|
||||
|
||||
@ -48,14 +43,6 @@ export class BrowserAnimation extends Animation {
|
||||
}
|
||||
}
|
||||
|
||||
export class NoopAnimation extends Animation {
|
||||
constructor() { super(); }
|
||||
|
||||
create(element: any, options?: AnimationOptions): AnimationPlayer {
|
||||
return new NoopAnimationPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
export class RendererAnimationPlayer implements AnimationPlayer {
|
||||
public parentPlayer: AnimationPlayer|null = null;
|
||||
private _started = false;
|
||||
|
@ -46,7 +46,7 @@ export class AnimationRendererFactory implements RendererFactory2 {
|
||||
this.delegate.begin();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
end() {
|
||||
this._zone.runOutsideAngular(() => this._engine.flush());
|
||||
if (this.delegate.end) {
|
||||
|
@ -5,6 +5,5 @@
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
export {NoopAnimation as ɵNoopAnimation, NoopAnimationBuilder as ɵNoopAnimationBuilder} from './animation_builder';
|
||||
export {BrowserAnimation as ɵBrowserAnimation, BrowserAnimationBuilder as ɵBrowserAnimationBuilder} from './animation_builder';
|
||||
export {AnimationRenderer as ɵAnimationRenderer, AnimationRendererFactory as ɵAnimationRendererFactory} from './animation_renderer';
|
||||
|
@ -7,22 +7,15 @@
|
||||
*/
|
||||
|
||||
import {AnimationBuilder} from '@angular/animations';
|
||||
import {AnimationDriver, ɵAnimationEngine as AnimationEngine, ɵAnimationStyleNormalizer as AnimationStyleNormalizer, ɵDomAnimationEngine as DomAnimationEngine, ɵNoopAnimationDriver as NoopAnimationDriver, ɵNoopAnimationEngine as NoopAnimationEngine, ɵNoopAnimationStyleNormalizer as NoopAnimationStyleNormalizer, ɵWebAnimationsDriver as WebAnimationsDriver, ɵWebAnimationsStyleNormalizer as WebAnimationsStyleNormalizer, ɵsupportsWebAnimations as supportsWebAnimations} from '@angular/animations/browser';
|
||||
import {AnimationDriver, ɵAnimationEngine as AnimationEngine, ɵAnimationStyleNormalizer as AnimationStyleNormalizer, ɵNoopAnimationDriver as NoopAnimationDriver, ɵWebAnimationsDriver as WebAnimationsDriver, ɵWebAnimationsStyleNormalizer as WebAnimationsStyleNormalizer, ɵsupportsWebAnimations as supportsWebAnimations} from '@angular/animations/browser';
|
||||
import {Injectable, NgZone, Provider, RendererFactory2} from '@angular/core';
|
||||
import {ɵDomRendererFactory2 as DomRendererFactory2} from '@angular/platform-browser';
|
||||
|
||||
import {BrowserAnimationBuilder, NoopAnimationBuilder} from './animation_builder';
|
||||
import {BrowserAnimationBuilder} from './animation_builder';
|
||||
import {AnimationRendererFactory} from './animation_renderer';
|
||||
|
||||
@Injectable()
|
||||
export class InjectableAnimationEngine extends DomAnimationEngine {
|
||||
constructor(driver: AnimationDriver, normalizer: AnimationStyleNormalizer) {
|
||||
super(driver, normalizer);
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class InjectableNoopAnimationEngine extends NoopAnimationEngine {
|
||||
export class InjectableAnimationEngine extends AnimationEngine {
|
||||
constructor(driver: AnimationDriver, normalizer: AnimationStyleNormalizer) {
|
||||
super(driver, normalizer);
|
||||
}
|
||||
@ -44,13 +37,8 @@ export function instantiateRendererFactory(
|
||||
return new AnimationRendererFactory(renderer, engine, zone);
|
||||
}
|
||||
|
||||
/**
|
||||
* Separate providers from the actual module so that we can do a local modification in Google3 to
|
||||
* include them in the BrowserModule.
|
||||
*/
|
||||
export const BROWSER_ANIMATIONS_PROVIDERS: Provider[] = [
|
||||
{provide: AnimationBuilder, useClass: NoopAnimationBuilder},
|
||||
{provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver},
|
||||
const SHARED_ANIMATION_PROVIDERS: Provider[] = [
|
||||
{provide: AnimationBuilder, useClass: BrowserAnimationBuilder},
|
||||
{provide: AnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer},
|
||||
{provide: AnimationEngine, useClass: InjectableAnimationEngine}, {
|
||||
provide: RendererFactory2,
|
||||
@ -59,21 +47,18 @@ export const BROWSER_ANIMATIONS_PROVIDERS: Provider[] = [
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* Separate providers from the actual module so that we can do a local modification in Google3 to
|
||||
* include them in the BrowserModule.
|
||||
*/
|
||||
export const BROWSER_ANIMATIONS_PROVIDERS: Provider[] = [
|
||||
{provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver},
|
||||
...SHARED_ANIMATION_PROVIDERS
|
||||
];
|
||||
|
||||
/**
|
||||
* Separate providers from the actual module so that we can do a local modification in Google3 to
|
||||
* include them in the BrowserTestingModule.
|
||||
*/
|
||||
export const BROWSER_NOOP_ANIMATIONS_PROVIDERS: Provider[] = [
|
||||
{provide: AnimationBuilder, useClass: BrowserAnimationBuilder},
|
||||
{provide: AnimationDriver, useClass: NoopAnimationDriver},
|
||||
{provide: AnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer}, {
|
||||
provide: AnimationEngine,
|
||||
useClass: NoopAnimationEngine,
|
||||
deps: [AnimationDriver, AnimationStyleNormalizer]
|
||||
},
|
||||
{
|
||||
provide: RendererFactory2,
|
||||
useFactory: instantiateRendererFactory,
|
||||
deps: [DomRendererFactory2, AnimationEngine, NgZone]
|
||||
}
|
||||
];
|
||||
export const BROWSER_NOOP_ANIMATIONS_PROVIDERS: Provider[] =
|
||||
[{provide: AnimationDriver, useClass: NoopAnimationDriver}, ...SHARED_ANIMATION_PROVIDERS];
|
||||
|
Reference in New Issue
Block a user