Skip to content

Commit

Permalink
fix: animations (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
darklight365 authored May 10, 2024
1 parent c833635 commit ad576bf
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions packages/angular/src/lib/animations/animations.module.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
import { NgModule, Injectable, Inject, NgZone, RendererFactory2, Optional, SkipSelf } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { AnimationBuilder } from '@angular/animations';
import { AnimationBuilder, ɵBrowserAnimationBuilder as BrowserAnimationBuilder } from '@angular/animations';

import { AnimationDriver, ɵAnimationStyleNormalizer as AnimationStyleNormalizer, ɵWebAnimationsStyleNormalizer as WebAnimationsStyleNormalizer, ɵAnimationEngine as AnimationEngine } from '@angular/animations/browser';

// import { ɵAnimationRendererFactory as AnimationRendererFactory, ɵBrowserAnimationBuilder as BrowserAnimationBuilder } from '@angular/platform-browser/animations';
import { AnimationDriver, ɵAnimationRendererFactory as AnimationRendererFactory, ɵAnimationStyleNormalizer as AnimationStyleNormalizer, ɵWebAnimationsStyleNormalizer as WebAnimationsStyleNormalizer, ɵAnimationEngine as AnimationEngine } from '@angular/animations/browser';

// import { NativeScriptModule } from "../nativescript.module";
// import { NativeScriptRendererFactory } from '../nativescript-renderer';
import { NativeScriptRendererFactory } from '../nativescript-renderer';
import { NativeScriptAnimationDriver } from './animation-driver';
import { throwIfAlreadyLoaded } from '../utils/general';
import { NativeScriptCommonModule } from '../nativescript-common.module';

@Injectable()
export class InjectableAnimationEngine extends AnimationEngine {
constructor(@Inject(DOCUMENT) doc: any, driver: AnimationDriver, normalizer: AnimationStyleNormalizer) {
super(doc.body, driver, normalizer);
super(doc, 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 instantiateRendererFactory(renderer: NativeScriptRendererFactory, engine: AnimationEngine, zone: NgZone) {
return new AnimationRendererFactory(renderer, engine, zone);
}

export function instantiateDefaultStyleNormalizer() {
return new WebAnimationsStyleNormalizer();
Expand All @@ -38,17 +36,17 @@ export function instantiateDefaultStyleNormalizer() {
provide: AnimationDriver,
useFactory: instantiateSupportedAnimationDriver,
},
// { provide: AnimationBuilder, useClass: BrowserAnimationBuilder },
{ provide: AnimationBuilder, useClass: BrowserAnimationBuilder },
{
provide: AnimationStyleNormalizer,
useFactory: instantiateDefaultStyleNormalizer,
},
{ provide: AnimationEngine, useClass: InjectableAnimationEngine },
// {
// provide: RendererFactory2,
// useFactory: instantiateRendererFactory,
// deps: [NativeScriptRendererFactory, AnimationEngine, NgZone],
// },
{
provide: RendererFactory2,
useFactory: instantiateRendererFactory,
deps: [NativeScriptRendererFactory, AnimationEngine, NgZone],
},
],
})
export class NativeScriptAnimationsModule {
Expand Down

0 comments on commit ad576bf

Please sign in to comment.