2017-02-24 14:47:36 -08:00
|
|
|
/**
|
|
|
|
|
* @license
|
2020-05-19 12:08:49 -07:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2017-02-24 14:47:36 -08:00
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
2021-02-21 14:17:53 +01:00
|
|
|
import {ModuleWithProviders, NgModule} from '@angular/core';
|
2017-02-28 17:49:37 -08:00
|
|
|
import {BrowserModule} from '@angular/platform-browser';
|
2017-02-24 14:47:36 -08:00
|
|
|
|
|
|
|
|
import {BROWSER_ANIMATIONS_PROVIDERS, BROWSER_NOOP_ANIMATIONS_PROVIDERS} from './providers';
|
|
|
|
|
|
2021-02-21 14:17:53 +01:00
|
|
|
/**
|
|
|
|
|
* Object used to configure the behavior of {@link BrowserAnimationsModule}
|
|
|
|
|
* @publicApi
|
|
|
|
|
*/
|
|
|
|
|
export interface BrowserAnimationsModuleConfig {
|
|
|
|
|
/**
|
|
|
|
|
* Whether animations should be disabled. Passing this is identical to providing the
|
|
|
|
|
* `NoopAnimationsModule`, but it can be controlled based on a runtime value.
|
|
|
|
|
*/
|
|
|
|
|
disableAnimations?: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-24 14:47:36 -08:00
|
|
|
/**
|
2018-08-22 08:52:19 -07:00
|
|
|
* Exports `BrowserModule` with additional [dependency-injection providers](guide/glossary#provider)
|
|
|
|
|
* for use with animations. See [Animations](guide/animations).
|
2018-10-19 12:12:20 +01:00
|
|
|
* @publicApi
|
2017-02-24 14:47:36 -08:00
|
|
|
*/
|
|
|
|
|
@NgModule({
|
2017-07-20 14:36:25 -07:00
|
|
|
exports: [BrowserModule],
|
2017-02-24 14:47:36 -08:00
|
|
|
providers: BROWSER_ANIMATIONS_PROVIDERS,
|
|
|
|
|
})
|
|
|
|
|
export class BrowserAnimationsModule {
|
2021-02-21 14:17:53 +01:00
|
|
|
/**
|
|
|
|
|
* Configures the module based on the specified object.
|
|
|
|
|
*
|
|
|
|
|
* @param config Object used to configure the behavior of the `BrowserAnimationsModule`.
|
|
|
|
|
* @see `BrowserAnimationsModuleConfig`
|
|
|
|
|
*
|
|
|
|
|
* @usageNotes
|
|
|
|
|
* When registering the `BrowserAnimationsModule`, you can use the `withConfig`
|
|
|
|
|
* function as follows:
|
|
|
|
|
* ```
|
|
|
|
|
* @NgModule({
|
|
|
|
|
* imports: [BrowserAnimationsModule.withConfig(config)]
|
|
|
|
|
* })
|
|
|
|
|
* class MyNgModule {}
|
|
|
|
|
* ```
|
|
|
|
|
*/
|
|
|
|
|
static withConfig(config: BrowserAnimationsModuleConfig):
|
|
|
|
|
ModuleWithProviders<BrowserAnimationsModule> {
|
|
|
|
|
return {
|
|
|
|
|
ngModule: BrowserAnimationsModule,
|
|
|
|
|
providers: config.disableAnimations ? BROWSER_NOOP_ANIMATIONS_PROVIDERS :
|
|
|
|
|
BROWSER_ANIMATIONS_PROVIDERS
|
|
|
|
|
};
|
|
|
|
|
}
|
2017-02-24 14:47:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2018-08-22 08:52:19 -07:00
|
|
|
* A null player that must be imported to allow disabling of animations.
|
2018-10-19 12:12:20 +01:00
|
|
|
* @publicApi
|
2017-02-24 14:47:36 -08:00
|
|
|
*/
|
|
|
|
|
@NgModule({
|
2017-07-20 14:36:25 -07:00
|
|
|
exports: [BrowserModule],
|
2017-02-24 14:47:36 -08:00
|
|
|
providers: BROWSER_NOOP_ANIMATIONS_PROVIDERS,
|
|
|
|
|
})
|
|
|
|
|
export class NoopAnimationsModule {
|
|
|
|
|
}
|