diff --git a/CrossPlatformModules.csproj b/CrossPlatformModules.csproj index 950037051..9688da4ba 100644 --- a/CrossPlatformModules.csproj +++ b/CrossPlatformModules.csproj @@ -134,6 +134,20 @@ page-title-icon.xml + + + + + animation.d.ts + + + animation.d.ts + + + animation.d.ts + + + list-picker.xml @@ -791,6 +805,13 @@ + + + + + + Designer + @@ -798,7 +819,9 @@ - + + Designer + Designer @@ -1741,7 +1764,9 @@ PreserveNewest - + + + PreserveNewest diff --git a/application/Readme.md b/application/Readme.md index e5badda4c..cc215353f 100644 --- a/application/Readme.md +++ b/application/Readme.md @@ -1,6 +1,4 @@ -Use the frame in the following way: - -### To navigate to the starting page of the application +# Ani ```javascript // put this in the bootstrap.js var app = require("application"); diff --git a/apps/animations/app.css b/apps/animations/app.css new file mode 100644 index 000000000..c59011f60 --- /dev/null +++ b/apps/animations/app.css @@ -0,0 +1,3 @@ +page { + /* CSS styles */ +} \ No newline at end of file diff --git a/apps/animations/app.ts b/apps/animations/app.ts new file mode 100644 index 000000000..2baebd169 --- /dev/null +++ b/apps/animations/app.ts @@ -0,0 +1,8 @@ +import application = require("application"); +import trace = require("trace"); + +trace.enable(); +trace.setCategories(trace.categories.concat(trace.categories.Animation)); + +application.mainModule = "main-page"; +application.start(); diff --git a/apps/animations/main-page.ts b/apps/animations/main-page.ts new file mode 100644 index 000000000..39c7d293f --- /dev/null +++ b/apps/animations/main-page.ts @@ -0,0 +1,93 @@ +import observable = require("data/observable"); +import pages = require("ui/page"); +import buttonModule = require("ui/button"); +import abs = require("ui/layouts/absolute-layout"); +import animationModule = require("ui/animation"); +import colorModule = require("color"); +import model = require("./model"); + +var vm = new model.ViewModel(); + +var page: pages.Page; +var panel: abs.AbsoluteLayout; +var button1: buttonModule.Button; +var button2: buttonModule.Button; +var button3: buttonModule.Button; +var buttonAnimation: animationModule.Animation; +var panelAnimation: animationModule.Animation; + +export function pageLoaded(args: observable.EventData) { + page = args.object; + page.bindingContext = vm; + panel = page.getViewById("panel1"); + button1 = page.getViewById("button1"); + button2 = page.getViewById("button2"); + button3 = page.getViewById("button3"); +} + +export function onSlideOut(args: observable.EventData) { + console.log("onSlideOut"); + var curve = page.android ? new android.view.animation.AccelerateInterpolator(1) : UIViewAnimationCurve.UIViewAnimationCurveEaseIn; + + var buttonAnimations = [ + { target: button1, translate: { x: -240, y: 0 }, scale: { x: 0.5, y: 0.5 }, opacity: 0, duration: vm.duration, delay: 0, iterations: vm.iterations, curve: curve }, + { target: button2, translate: { x: -240, y: 0 }, scale: { x: 0.5, y: 0.5 }, opacity: 0, duration: vm.duration, delay: vm.duration, iterations: vm.iterations, curve: curve }, + { target: button3, translate: { x: -240, y: 0 }, scale: { x: 0.5, y: 0.5 }, opacity: 0, duration: vm.duration, delay: vm.duration * 2, iterations: vm.iterations, curve: curve }, + ] + buttonAnimation = new animationModule.Animation(buttonAnimations, vm.playSequentially); + + panelAnimation = panel.createAnimation({ opacity: 0, scale: { x: 0.5, y: 0.5 }, rotate: -360, backgroundColor: new colorModule.Color("red"), duration: vm.duration, iterations: vm.iterations }); + + buttonAnimation.play().finished + .then(() => panelAnimation.play().finished) + .catch((e) => console.log(e.message)); +} + +export function onSlideIn(args: observable.EventData) { + console.log("onSlideIn"); + var curve = page.android ? new android.view.animation.DecelerateInterpolator(1) : UIViewAnimationCurve.UIViewAnimationCurveEaseOut; + + panelAnimation = panel.createAnimation({ opacity: 1, scale: { x: 1, y: 1 }, rotate: 0, backgroundColor: new colorModule.Color("yellow"), duration: vm.duration, iterations: vm.iterations }); + + var buttonAnimations = [ + { target: button3, translate: { x: 0, y: 0 }, scale: { x: 1, y: 1 }, opacity: 1, duration: vm.duration, delay: 0, iterations: vm.iterations, curve: curve }, + { target: button2, translate: { x: 0, y: 0 }, scale: { x: 1, y: 1 }, opacity: 1, duration: vm.duration, delay: vm.duration, iterations: vm.iterations, curve: curve }, + { target: button1, translate: { x: 0, y: 0 }, scale: { x: 1, y: 1 }, opacity: 1, duration: vm.duration, delay: vm.duration * 2, iterations: vm.iterations, curve: curve }, + ] + buttonAnimation = new animationModule.Animation(buttonAnimations, vm.playSequentially); + + panelAnimation.play().finished + .then(() => buttonAnimation.play().finished) + .catch((e) => console.log(e.message)); +} + +export function onCancel(args: observable.EventData) { + console.log("onCancel"); + if (panelAnimation.isPlaying) { + panelAnimation.cancel(); + } + if (buttonAnimation.isPlaying) { + buttonAnimation.cancel(); + } +} + +export function onTap(args: observable.EventData) { + console.log((args.object).text); +} + +export function onSingle(args: observable.EventData) { + console.log("onSingle"); + button1.animate({ + opacity: 0.75, + backgroundColor: new colorModule.Color("Red"), + translate: { x: 100, y: 100 }, + scale: { x: 2, y: 2 }, + rotate: 180, + duration: vm.duration, + delay: 0, + iterations: vm.iterations, + curve: button1.ios ? UIViewAnimationCurve.UIViewAnimationCurveEaseIn : new android.view.animation.AccelerateInterpolator(1), + }) + .then(() => console.log("Animation finished")) + .catch((e) => console.log(e.message)); +} \ No newline at end of file diff --git a/apps/animations/main-page.xml b/apps/animations/main-page.xml new file mode 100644 index 000000000..8a132ce87 --- /dev/null +++ b/apps/animations/main-page.xml @@ -0,0 +1,30 @@ + + + + +