Skip to content

feat: update to Angular 5 animations and add support for AnimationBuilder #1114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"nativescript-angular": "file:../../nativescript-angular",
"nativescript-intl": "^3.0.0",
"reflect-metadata": "~0.1.8",
"rxjs": "5.5.2",
"rxjs": "^5.5.4",
"tns-core-modules": "next",
"zone.js": "^0.8.4"
},
Expand Down
20 changes: 16 additions & 4 deletions nativescript-angular/animations/animation-driver.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { AnimationPlayer } from "@angular/animations";
import { AnimationDriver } from "@angular/animations/browser";
import { ProxyViewContainer } from "tns-core-modules/ui/proxy-view-container";
import { createSelector, SelectorCore } from "tns-core-modules/ui/styling/css-selector";
import { CssAnimationProperty } from "tns-core-modules/ui/core/properties";
import { eachDescendant } from "tns-core-modules/ui/core/view";
import { ProxyViewContainer } from "tns-core-modules/ui/proxy-view-container";

import { NativeScriptAnimationPlayer } from "./animation-player";
import {
Expand All @@ -11,7 +13,6 @@ import {
import { NgView, InvisibleNode } from "../element-registry";
import { animationsLog as traceLog } from "../trace";

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

interface ViewMatchResult {
found: boolean;
Expand Down Expand Up @@ -68,8 +69,14 @@ class Selector {
}

export class NativeScriptAnimationDriver implements AnimationDriver {
validateStyleProperty(prop: string): boolean {
throw new Error("Not implemented!");
private static validProperties = [
...CssAnimationProperty._getPropertyNames(),
"transform",
];

validateStyleProperty(property: string): boolean {
traceLog(`CssAnimationProperty.validateStyleProperty: ${property}`);
return NativeScriptAnimationDriver.validProperties.indexOf(property) !== -1;
}

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

// Checking if the parent is our fake body object
if (elm1["isOverride"]) {
return true;
}

const params: ViewMatchParams = { originalView: elm2 };
const result: ViewMatchResult = this.visitDescendants(elm1, viewMatches, params);

Expand Down
23 changes: 0 additions & 23 deletions nativescript-angular/animations/animation-engine.ts

This file was deleted.

14 changes: 7 additions & 7 deletions nativescript-angular/animations/animations.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ 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 { NativeScriptAnimationEngine } from "./animation-engine";
import { NativeScriptAnimationDriver } from "./animation-driver";
import { NativeScriptModule } from "../nativescript.module";
import { NativeScriptRendererFactory } from "../renderer";
import { NativeScriptAnimationDriver } from "./animation-driver";

@Injectable()
export class InjectableAnimationEngine extends NativeScriptAnimationEngine {
export class InjectableAnimationEngine extends AnimationEngine {
constructor(driver: AnimationDriver, normalizer: AnimationStyleNormalizer) {
super(driver, normalizer);
}
Expand All @@ -30,7 +30,7 @@ export function instantiateSupportedAnimationDriver() {
}

export function instantiateRendererFactory(
renderer: NativeScriptRendererFactory, engine: NativeScriptAnimationEngine, zone: NgZone) {
renderer: NativeScriptRendererFactory, engine: AnimationEngine, zone: NgZone) {
return new AnimationRendererFactory(renderer, engine, zone);
}

Expand All @@ -39,14 +39,14 @@ export function instantiateDefaultStyleNormalizer() {
}

export const NATIVESCRIPT_ANIMATIONS_PROVIDERS: Provider[] = [
{provide: AnimationBuilder, useClass: BrowserAnimationBuilder},
{provide: AnimationDriver, useFactory: instantiateSupportedAnimationDriver},
{provide: AnimationBuilder, useClass: BrowserAnimationBuilder},
{provide: AnimationStyleNormalizer, useFactory: instantiateDefaultStyleNormalizer},
{provide: NativeScriptAnimationEngine, useClass: InjectableAnimationEngine},
{provide: AnimationEngine, useClass: InjectableAnimationEngine},
{
provide: RendererFactory2,
useFactory: instantiateRendererFactory,
deps: [NativeScriptRendererFactory, NativeScriptAnimationEngine, NgZone]
deps: [NativeScriptRendererFactory, AnimationEngine, NgZone]
}
];

Expand Down

This file was deleted.

164 changes: 0 additions & 164 deletions nativescript-angular/animations/private-imports/render/shared.ts

This file was deleted.

Loading