forked from NativeScript/nativescript-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimations.ts
More file actions
52 lines (43 loc) · 1.9 KB
/
animations.ts
File metadata and controls
52 lines (43 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { NgModule, Injectable, NgZone, Provider, RendererFactory2 } from "@angular/core";
import {
AnimationDriver,
ɵAnimationEngine as AnimationEngine,
ɵAnimationStyleNormalizer as AnimationStyleNormalizer,
ɵWebAnimationsStyleNormalizer as WebAnimationsStyleNormalizer
} from "@angular/animations/browser";
import { ɵAnimationRendererFactory as AnimationRendererFactory } from "@angular/platform-browser/animations";
import { NativeScriptAnimationEngine } from "./animations/animation-engine";
import { NativeScriptAnimationDriver } from "./animations/animation-driver";
import { NativeScriptModule } from "./nativescript.module";
import { NativeScriptRendererFactory } from "./renderer";
@Injectable()
export class InjectableAnimationEngine extends NativeScriptAnimationEngine {
constructor(driver: AnimationDriver, normalizer: AnimationStyleNormalizer) {
super(driver, normalizer);
}
}
export function instantiateSupportedAnimationDriver() {
return new NativeScriptAnimationDriver();
}
export function instantiateRendererFactory(
renderer: NativeScriptRendererFactory, engine: AnimationEngine, zone: NgZone) {
return new AnimationRendererFactory(renderer, engine, zone);
}
export function instanciateDefaultStyleNormalizer() {
return new WebAnimationsStyleNormalizer();
}
export const NATIVESCRIPT_ANIMATIONS_PROVIDERS: Provider[] = [
{provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver},
{provide: AnimationStyleNormalizer, useFactory: instanciateDefaultStyleNormalizer},
{provide: AnimationEngine, useClass: InjectableAnimationEngine}, {
provide: RendererFactory2,
useFactory: instantiateRendererFactory,
deps: [NativeScriptRendererFactory, AnimationEngine, NgZone]
}
];
@NgModule({
imports: [NativeScriptModule],
providers: NATIVESCRIPT_ANIMATIONS_PROVIDERS,
})
export class NativeScriptAnimationsModule {
}