Skip to content

Commit 4ad924a

Browse files
committed
feat: add example with AnimationBuilder
1 parent 498e992 commit 4ad924a

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

app/animation-builder.component.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { AnimationBuilder, style, animate } from '@angular/animations';
2+
import { Component, ViewChild } from '@angular/core';
3+
4+
@Component({
5+
template: `
6+
<Button #button (tap)="makeAnimation()" class="btn btn-primary" text="Tap to disappear!"></Button>
7+
`
8+
})
9+
export class AnimationBuilderComponent {
10+
@ViewChild('button')
11+
private button;
12+
13+
constructor(private _builder: AnimationBuilder) {}
14+
15+
makeAnimation() {
16+
const myAnimation = this._builder.build([
17+
style({ "opacity": 1 }),
18+
animate(1000, style({ "opacity": 0 }))
19+
]);
20+
21+
const player = myAnimation.create(this.button.nativeElement);
22+
23+
player.play();
24+
}
25+
}

app/animations-list.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Link {
1818
})
1919
export class AnimationsListComponent {
2020
public links: Link[] = [
21+
new Link("Animation builder", "/builder"),
2122
new Link("External animation", "/external"),
2223
new Link("Selector", "/selector"),
2324
new Link("Query with stagger", "/query-stagger"),

app/app.routing.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Routes } from "@angular/router";
33
import { NativeScriptRouterModule } from "nativescript-angular/router";
44

55
import { AnimationsListComponent } from "./animations-list.component";
6+
import { AnimationBuilderComponent } from "./animation-builder.component";
67
import { ExternalAnimationComponent } from "./external-animation.component";
78
import { FadeInOutComponent } from "./fade-in-out.component";
89
import { OptionsComponent } from "./options.component";
@@ -14,6 +15,7 @@ import { QueryStaggerComponent } from "./query-stagger.component";
1415
const routes: Routes = [
1516
{ path: "", pathMatch: "full", redirectTo: "list" },
1617
{ path: "list", component: AnimationsListComponent },
18+
{ path: "builder", component: AnimationBuilderComponent },
1719
{ path: "external", component: ExternalAnimationComponent },
1820
{ path: "fade-in-out", component: FadeInOutComponent },
1921
{ path: "options", component: OptionsComponent },
@@ -32,6 +34,7 @@ export class AppRoutingModule { }
3234

3335
export const routedComponents = [
3436
AnimationsListComponent,
37+
AnimationBuilderComponent,
3538
ExternalAnimationComponent,
3639
FadeInOutComponent,
3740
OptionsComponent,

0 commit comments

Comments
 (0)