Skip to content

Commit 97fd50b

Browse files
author
vakrilov
committed
Minor improvements
1 parent d4b59b8 commit 97fd50b

File tree

9 files changed

+5402
-22
lines changed

9 files changed

+5402
-22
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# NativeScript Routable Animations
2+
3+
A NativeScript Angular applications showcasing [angular routable animations](https://www.yearofmoo.com/2017/06/new-wave-of-animation-features.html#routable-animations).

app/app.component.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,28 @@ import {
1212
const slideLeft = [
1313
query(':leave', style({ transform: 'translateX(0)' })),
1414
query(':enter', style({ transform: 'translateX(-400)' })),
15+
1516
group([
16-
query(':leave', animate(1000, style({ transform: 'translateX(400)' }))),
17-
query(':enter', animate(2000, style({ transform: 'translateX(0)' }))),
18-
])
17+
query(':leave', animate(500, style({ transform: 'translateX(400)' }))),
18+
query(':enter', animate(500, style({ transform: 'translateX(0)' }))),
19+
], { delay: 10 }) // Needed because a wierd animation scheduling bug in IOS
1920
]
2021

2122
const slideRight = [
2223
query(':leave', style({ transform: 'translateX(0)'})),
2324
query(':enter', style({ transform: 'translateX(400)'})),
2425

2526
group([
26-
query(':leave', animate(2000, style({ transform: 'translateX(-400)' }))),
27-
query(':enter', animate(2000, style({ transform: 'translateX(0)' }))),
28-
])
27+
query(':leave', animate(500, style({ transform: 'translateX(-400)' })), { delay: 100 }),
28+
query(':enter', animate(500, style({ transform: 'translateX(0)' })), { delay: 100 }),
29+
], { delay: 10 }) // Needed because a wierd animation scheduling bug in IOS
2930
]
3031

3132
@Component({
3233
template: `
33-
<div [@routeAnimation]="prepRouteState(routerOutlet)">
34+
<GridLayout [@routeAnimation]="prepRouteState(routerOutlet)">
3435
<router-outlet #routerOutlet="outlet"></router-outlet>
35-
</div>
36+
</GridLayout>
3637
`,
3738
animations: [
3839
trigger('routeAnimation', [
@@ -45,7 +46,6 @@ export class AppComponent {
4546
prepRouteState(outlet: any) {
4647
return outlet.activatedRouteData['animation'] || 'firstPage';
4748
}
48-
4949
}
5050

5151

app/app.module.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { AppRoutingModule } from './app-routing.module';
77
import { HomeComponent } from './home/home.component';
88
import { SupportComponent } from './support/support.component';
99

10-
import { animationsTraceCategory, } from "nativescript-angular/trace";
10+
import { animationsTraceCategory } from "nativescript-angular/trace";
1111
import { setCategories, enable } from "trace";
1212
setCategories(animationsTraceCategory);
1313
enable();
@@ -20,10 +20,10 @@ enable();
2020
],
2121
bootstrap: [AppComponent],
2222
imports: [
23-
NativeScriptModule,
24-
NativeScriptAnimationsModule,
25-
AppRoutingModule,
23+
NativeScriptModule,
24+
NativeScriptAnimationsModule,
25+
AppRoutingModule,
2626
],
2727
schemas: [NO_ERRORS_SCHEMA],
2828
})
29-
export class AppModule {}
29+
export class AppModule { }

app/home/home.component.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<StackLayout>
2-
<Label text="home works!!"></Label>
3-
<Button text="placeholder 1"></Button>
4-
<Button text="placeholder 2"></Button>
2+
<Label text="Home Page" class="h1 text-center"></Label>
53

6-
<Button [nsRouterLink]="'/support'" text="support" backgroundColor="hotpink"></Button>
4+
<Button [nsRouterLink]="'/support'" text="go to support"
5+
backgroundColor="hotpink"></Button>
76
</StackLayout>
87

app/images/apple.jpg

-270 KB
Binary file not shown.

app/support/support.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<StackLayout>
2-
<Label text="support works!" ></Label>
3-
<Button [nsRouterLink]="'/'" text="Home"></Button>
2+
<Label text="Support Page" class="h1 text-center" ></Label>
3+
4+
<Button (tap)="router.back()" text="Go Back"></Button>
45
</StackLayout>

app/support/support.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, OnInit } from '@angular/core';
2+
import { RouterExtensions } from 'nativescript-angular/router';
23

34
@Component({
45
moduleId: module.id,
@@ -7,7 +8,8 @@ import { Component, OnInit } from '@angular/core';
78
})
89
export class SupportComponent implements OnInit {
910

10-
constructor() { }
11+
constructor(public router: RouterExtensions) {
12+
}
1113

1214
ngOnInit() {
1315
}

0 commit comments

Comments
 (0)