Skip to content

Commit 191f2a0

Browse files
sis0k0SvetoslavTsenov
authored andcommitted
feat: update to Angular 5 animations and add support for AnimationBuilder (#1114)
* wip: all styles are valid * refactor: use the transition animation engine from angular * refactor: provide a mocked document object with body (wip) * refactor: use property names list from CssAnimationProperty for validation * fix: include "transform" in valid animation property names * refactor: remove old private imports * refactor: unify parentNode access The logic for setting/getting template parent is delegated to the ViewBase class. * refactor: remove NativeScriptAnimationEngine * chore(ng-sample): update deps * fix: ignore setting property of 'null' objects * refactor: provide fake document object when bootstrapping the app * feat: provide support for AnimationBuilder * refactor: provide fake polyfill for global.document * chore: unpin rxjs versions * test: fix mocks * docs(Animations): add comment for using fake body object in Driver
1 parent f3b4b65 commit 191f2a0

17 files changed

+59
-2453
lines changed

Diff for: e2e/router/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"nativescript-angular": "file:../../nativescript-angular",
2626
"nativescript-intl": "^3.0.0",
2727
"reflect-metadata": "~0.1.8",
28-
"rxjs": "5.5.2",
28+
"rxjs": "^5.5.4",
2929
"tns-core-modules": "next",
3030
"zone.js": "^0.8.4"
3131
},

Diff for: nativescript-angular/animations/animation-driver.ts

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { AnimationPlayer } from "@angular/animations";
22
import { AnimationDriver } from "@angular/animations/browser";
3-
import { ProxyViewContainer } from "tns-core-modules/ui/proxy-view-container";
3+
import { createSelector, SelectorCore } from "tns-core-modules/ui/styling/css-selector";
4+
import { CssAnimationProperty } from "tns-core-modules/ui/core/properties";
45
import { eachDescendant } from "tns-core-modules/ui/core/view";
6+
import { ProxyViewContainer } from "tns-core-modules/ui/proxy-view-container";
57

68
import { NativeScriptAnimationPlayer } from "./animation-player";
79
import {
@@ -11,7 +13,6 @@ import {
1113
import { NgView, InvisibleNode } from "../element-registry";
1214
import { animationsLog as traceLog } from "../trace";
1315

14-
import { createSelector, SelectorCore } from "tns-core-modules/ui/styling/css-selector";
1516

1617
interface ViewMatchResult {
1718
found: boolean;
@@ -68,8 +69,14 @@ class Selector {
6869
}
6970

7071
export class NativeScriptAnimationDriver implements AnimationDriver {
71-
validateStyleProperty(prop: string): boolean {
72-
throw new Error("Not implemented!");
72+
private static validProperties = [
73+
...CssAnimationProperty._getPropertyNames(),
74+
"transform",
75+
];
76+
77+
validateStyleProperty(property: string): boolean {
78+
traceLog(`CssAnimationProperty.validateStyleProperty: ${property}`);
79+
return NativeScriptAnimationDriver.validProperties.indexOf(property) !== -1;
7380
}
7481

7582
matchesElement(element: NgView, rawSelector: string): boolean {
@@ -89,6 +96,11 @@ export class NativeScriptAnimationDriver implements AnimationDriver {
8996
`element1: ${elm1}, element2: ${elm2}`
9097
);
9198

99+
// Checking if the parent is our fake body object
100+
if (elm1["isOverride"]) {
101+
return true;
102+
}
103+
92104
const params: ViewMatchParams = { originalView: elm2 };
93105
const result: ViewMatchResult = this.visitDescendants(elm1, viewMatches, params);
94106

Diff for: nativescript-angular/animations/animation-engine.ts

-23
This file was deleted.

Diff for: nativescript-angular/animations/animations.module.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ import {
66
AnimationDriver,
77
ɵAnimationStyleNormalizer as AnimationStyleNormalizer,
88
ɵWebAnimationsStyleNormalizer as WebAnimationsStyleNormalizer,
9+
ɵAnimationEngine as AnimationEngine,
910
} from "@angular/animations/browser";
1011

1112
import {
1213
ɵAnimationRendererFactory as AnimationRendererFactory,
1314
ɵBrowserAnimationBuilder as BrowserAnimationBuilder,
1415
} from "@angular/platform-browser/animations";
1516

16-
import { NativeScriptAnimationEngine } from "./animation-engine";
17-
import { NativeScriptAnimationDriver } from "./animation-driver";
1817
import { NativeScriptModule } from "../nativescript.module";
1918
import { NativeScriptRendererFactory } from "../renderer";
19+
import { NativeScriptAnimationDriver } from "./animation-driver";
2020

2121
@Injectable()
22-
export class InjectableAnimationEngine extends NativeScriptAnimationEngine {
22+
export class InjectableAnimationEngine extends AnimationEngine {
2323
constructor(driver: AnimationDriver, normalizer: AnimationStyleNormalizer) {
2424
super(driver, normalizer);
2525
}
@@ -30,7 +30,7 @@ export function instantiateSupportedAnimationDriver() {
3030
}
3131

3232
export function instantiateRendererFactory(
33-
renderer: NativeScriptRendererFactory, engine: NativeScriptAnimationEngine, zone: NgZone) {
33+
renderer: NativeScriptRendererFactory, engine: AnimationEngine, zone: NgZone) {
3434
return new AnimationRendererFactory(renderer, engine, zone);
3535
}
3636

@@ -39,14 +39,14 @@ export function instantiateDefaultStyleNormalizer() {
3939
}
4040

4141
export const NATIVESCRIPT_ANIMATIONS_PROVIDERS: Provider[] = [
42-
{provide: AnimationBuilder, useClass: BrowserAnimationBuilder},
4342
{provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver},
43+
{provide: AnimationBuilder, useClass: BrowserAnimationBuilder},
4444
{provide: AnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer},
45-
{provide: NativeScriptAnimationEngine, useClass: InjectableAnimationEngine},
45+
{provide: AnimationEngine, useClass: InjectableAnimationEngine},
4646
{
4747
provide: RendererFactory2,
4848
useFactory: instantiateRendererFactory,
49-
deps: [NativeScriptRendererFactory, NativeScriptAnimationEngine, NgZone]
49+
deps: [NativeScriptRendererFactory, AnimationEngine, NgZone]
5050
}
5151
];
5252

Diff for: nativescript-angular/animations/private-imports/dsl/element_instruction_map.ts

-36
This file was deleted.

Diff for: nativescript-angular/animations/private-imports/render/shared.ts

-164
This file was deleted.

0 commit comments

Comments
 (0)