Skip to content

Commit ff5b703

Browse files
committed
Fix animation for rc5. Port animation examples too.
1 parent a032115 commit ff5b703

File tree

6 files changed

+18
-16
lines changed

6 files changed

+18
-16
lines changed

nativescript-angular/animation-player.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
1313

1414
private _subscriptions: Function[] = [];
1515
private _finished = false;
16+
private _started = false;
1617
private animation: KeyframeAnimation;
1718
private target: View;
1819

@@ -64,11 +65,10 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
6465
}
6566

6667
init(): void {
67-
throw new Error("Not implemented.");
6868
}
6969

7070
hasStarted(): boolean {
71-
throw new Error("Not implemented.");
71+
return this._started;
7272
}
7373

7474

@@ -77,13 +77,15 @@ export class NativeScriptAnimationPlayer implements AnimationPlayer {
7777
private _onFinish() {
7878
if (!this._finished) {
7979
this._finished = true;
80+
this._started = false;
8081
this._subscriptions.forEach(fn => fn());
8182
this._subscriptions = [];
8283
}
8384
}
8485

8586
play(): void {
8687
if (this.animation) {
88+
this._started = true;
8789
this.animation.play(this.target)
8890
.then(() => { this._onFinish(); })
8991
.catch((e) => { });

ng-sample/app/app.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ function makeExampleModule(componentType) {
7676
if (componentType.entries) {
7777
entries = componentType.entries;
7878
}
79+
entries.push(componentType);
7980
let providers = [];
8081
if (componentType.providers) {
8182
providers = componentType.providers
@@ -106,7 +107,12 @@ function makeExampleModule(componentType) {
106107
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(PageRouterOutletAppComponent));
107108
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(PageRouterOutletNestedAppComponent));
108109
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(ClearHistoryAppComponent));
109-
platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LoginAppComponent));
110+
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LoginAppComponent));
111+
//animations
112+
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationStatesTest));
113+
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationNgClassTest));
114+
//platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationKeyframesTest));
115+
platformNativeScriptDynamic().bootstrapModule(makeExampleModule(AnimationEnterLeaveTest));
110116

111117
// Livesync test
112118
// var cahcedUrl: string;
@@ -129,9 +135,3 @@ platformNativeScriptDynamic().bootstrapModule(makeExampleModule(LoginAppComponen
129135
// });
130136

131137
// nativeScriptBootstrap(LivesyncApp, [LivesyncTestRouterProviders]);
132-
133-
// animations
134-
//nativeScriptBootstrap(AnimationStatesTest);
135-
//nativeScriptBootstrap(AnimationNgClassTest);
136-
//nativeScriptBootstrap(AnimationKeyframesTest);
137-
//nativeScriptBootstrap(AnimationEnterLeaveTest);

ng-sample/app/examples/animation/animation-enter-leave-test.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Button text="Remove All" (tap)="onRemoveAllTap()"></Button>
44
<ScrollView>
55
<StackLayout>
6-
<Button *ngFor="let item of items" @state="'in'" text="{{ item }}" class="button" (tap)="onItemTap($event)"></Button>
6+
<Button *ngFor="let item of items" [@state]="'in'" text="{{ item }}" class="button" (tap)="onItemTap($event)"></Button>
77
</StackLayout>
88
</ScrollView>
9-
</StackLayout>
9+
</StackLayout>

ng-sample/app/examples/animation/animation-keyframes-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Component, trigger, style, animate, state, transition, keyframes } from
44
selector: 'animation-states',
55
template: `
66
<StackLayout>
7-
<Button text="Touch me!" @state=" isOn ? 'active' : 'inactive' " (tap)="onTap()"></Button>
7+
<Button text="Touch me!" [@state]=" isOn ? 'active' : 'inactive' " (tap)="onTap()"></Button>
88
</StackLayout>`,
99
animations: [
1010
trigger('state', [

ng-sample/app/examples/animation/animation-ngclass-test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {Observable} from "data/observable";
33

44
@Component({
55
selector: "main-component",
6-
templateUrl: "./examples/animation/animation-ngClass-test.html",
7-
styleUrls: [ "./examples/animation/animation-ngClass-test.css" ]
6+
templateUrl: "./examples/animation/animation-ngclass-test.html",
7+
styleUrls: [ "./examples/animation/animation-ngclass-test.css" ]
88
})
99
export class AnimationNgClassTest {
1010

@@ -20,4 +20,4 @@ export class AnimationNgClassTest {
2020
this.text = "Normal";
2121
}
2222
}
23-
}
23+
}

ng-sample/app/examples/animation/animation-states-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {Component, trigger, style, animate, state, transition } from '@angular/c
44
selector: 'animation-states',
55
template: `
66
<StackLayout>
7-
<Button text="Touch me!" @state=" isOn ? 'active' : 'inactive' " (tap)="onTap()"></Button>
7+
<Button text="Touch me!" [@state]=" isOn ? 'active' : 'inactive' " (tap)="onTap()"></Button>
88
</StackLayout>`,
99
animations: [
1010
trigger('state', [

0 commit comments

Comments
 (0)