mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
refactor: animation app (#5968)
This commit is contained in:
@@ -1,36 +1,15 @@
|
||||
import { EventData, NavigatedData } from "tns-core-modules/ui/page";
|
||||
import { AnimationDefinition, Animation } from "tns-core-modules/ui/animation";
|
||||
import { EventData, Page } from "tns-core-modules/ui/page";
|
||||
import { Frame } from "tns-core-modules/ui/frame";
|
||||
import { Button } from "tns-core-modules/ui/button";
|
||||
|
||||
let page;
|
||||
let label1;
|
||||
let label2;
|
||||
let currentFrame: Frame;
|
||||
|
||||
export function onNavigatedTo(args: NavigatedData) {
|
||||
page = args.object;
|
||||
label1 = page.getViewById("Label1");
|
||||
label2 = page.getViewById("Label2");
|
||||
export function onPageLoaded(args: EventData) {
|
||||
currentFrame = (<Page>args.object).frame;
|
||||
}
|
||||
|
||||
export function onPlaySequentially(args: EventData) {
|
||||
const definitions = new Array<AnimationDefinition>();
|
||||
definitions.push({ target: label1, translate: { x: 100, y: 0 }, duration: 500 });
|
||||
definitions.push({ target: label1, opacity: 0.1, duration: 500 });
|
||||
|
||||
const animationSet = new Animation(definitions, true);
|
||||
animationSet.play()
|
||||
.then(() => {
|
||||
label1.text = "Label1 animated sequentially!";
|
||||
});
|
||||
}
|
||||
|
||||
export function onPlaySimultaneously(args: EventData) {
|
||||
const definitions = new Array<AnimationDefinition>();
|
||||
definitions.push({ target: label2, translate: { x: 0, y: 100 }, duration: 500 });
|
||||
definitions.push({ target: label2, opacity: 0.1, duration: 500 });
|
||||
|
||||
const animationSet = new Animation(definitions, true);
|
||||
animationSet.play()
|
||||
.then(() => {
|
||||
label2.text = "Label2 animated simultaneously!";
|
||||
});
|
||||
export function onButtonTap(args: EventData) {
|
||||
const clickedButton = <Button>args.object;
|
||||
const destination = "./" + clickedButton.text + "/page";
|
||||
currentFrame.navigate(destination);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user