feat(platform-browser): add token marking which the type of animation module nearest in the injector tree (#23075)
PR Close #23075
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
|
||||
import {AnimationBuilder} from '@angular/animations';
|
||||
import {AnimationDriver, ɵAnimationEngine as AnimationEngine, ɵAnimationStyleNormalizer as AnimationStyleNormalizer, ɵCssKeyframesDriver as CssKeyframesDriver, ɵ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 {Injectable, InjectionToken, NgZone, Provider, RendererFactory2} from '@angular/core';
|
||||
import {ɵDomRendererFactory2 as DomRendererFactory2} from '@angular/platform-browser';
|
||||
|
||||
import {BrowserAnimationBuilder} from './animation_builder';
|
||||
@ -34,6 +34,12 @@ export function instantiateRendererFactory(
|
||||
return new AnimationRendererFactory(renderer, engine, zone);
|
||||
}
|
||||
|
||||
/**
|
||||
* @experimental Animation support is experimental.
|
||||
*/
|
||||
export const ANIMATION_MODULE_TYPE =
|
||||
new InjectionToken<'NoopAnimations'|'BrowserAnimations'>('AnimationModuleType');
|
||||
|
||||
const SHARED_ANIMATION_PROVIDERS: Provider[] = [
|
||||
{provide: AnimationBuilder, useClass: BrowserAnimationBuilder},
|
||||
{provide: AnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer},
|
||||
@ -50,12 +56,14 @@ const SHARED_ANIMATION_PROVIDERS: Provider[] = [
|
||||
*/
|
||||
export const BROWSER_ANIMATIONS_PROVIDERS: Provider[] = [
|
||||
{provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver},
|
||||
...SHARED_ANIMATION_PROVIDERS
|
||||
{provide: ANIMATION_MODULE_TYPE, useValue: 'BrowserAnimations'}, ...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: AnimationDriver, useClass: NoopAnimationDriver}, ...SHARED_ANIMATION_PROVIDERS];
|
||||
export const BROWSER_NOOP_ANIMATIONS_PROVIDERS: Provider[] = [
|
||||
{provide: AnimationDriver, useClass: NoopAnimationDriver},
|
||||
{provide: ANIMATION_MODULE_TYPE, useValue: 'NoopAnimations'}, ...SHARED_ANIMATION_PROVIDERS
|
||||
];
|
||||
|
Reference in New Issue
Block a user