diff --git a/CrossPlatformModules.csproj b/CrossPlatformModules.csproj index 950037051..34ba87a53 100644 --- a/CrossPlatformModules.csproj +++ b/CrossPlatformModules.csproj @@ -134,6 +134,19 @@ page-title-icon.xml + + + + animation.d.ts + + + animation.d.ts + + + animation.d.ts + + + list-picker.xml @@ -791,6 +804,13 @@ + + + + + + Designer + @@ -798,7 +818,9 @@ - + + Designer + Designer @@ -1742,6 +1764,8 @@ 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..7b31af095 --- /dev/null +++ b/apps/animations/main-page.ts @@ -0,0 +1,131 @@ +import observable = require("data/observable"); +import pages = require("ui/page"); +import buttonModule = require("ui/button"); +import abs = require("ui/layouts/absolute-layout"); +import animation = require("ui/animation"); +import colorModule = require("color"); +import model = require("./model"); + +var vm = new model.ViewModel(); + +var page: pages.Page; +var panel1: abs.AbsoluteLayout; +var button1: buttonModule.Button; +var button2: buttonModule.Button; +var button3: buttonModule.Button; +var cancelToken: any; + +export function pageLoaded(args: observable.EventData) { + page = args.object; + page.bindingContext = vm; + panel1 = page.getViewById("panel1"); + button1 = page.getViewById("button1"); + button2 = page.getViewById("button2"); + button3 = page.getViewById("button3"); +} + +export function onSlideOut(args: observable.EventData) { + var animations: Array; + + animations = new Array(); + animations.push({ target: button1, property: animation.Properties.translate, value: { x: -240, y: 0 }, duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + animations.push({ target: button1, property: animation.Properties.scale, value: { x: 0.5, y: 0.5 }, duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + animations.push({ target: button1, property: animation.Properties.opacity, value: 0, duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + + animations.push({ target: button2, property: animation.Properties.translate, value: { x: -240, y: 0 }, duration: vm.duration, delay: vm.duration, repeatCount: vm.repeatCount }); + animations.push({ target: button2, property: animation.Properties.scale, value: { x: 0.5, y: 0.5 }, duration: vm.duration, delay: vm.duration, repeatCount: vm.repeatCount }); + animations.push({ target: button2, property: animation.Properties.opacity, value: 0, duration: vm.duration, delay: vm.duration, repeatCount: vm.repeatCount }); + + animations.push({ target: button3, property: animation.Properties.translate, value: { x: -240, y: 0 }, duration: vm.duration, delay: vm.duration * 2, repeatCount: vm.repeatCount }); + animations.push({ target: button3, property: animation.Properties.scale, value: { x: 0, y: 0 }, duration: vm.duration, delay: vm.duration * 2, repeatCount: vm.repeatCount }); + animations.push({ target: button3, property: animation.Properties.opacity, value: 0, duration: vm.duration, delay: vm.duration * 2, repeatCount: vm.repeatCount }); + + configureAnimationCurve(animations, true); + + cancelToken = animation.start(animations, vm.playSequentially, (cancelled?: boolean) => { + if (cancelled) { + console.log("Buttons slide out animations cancelled"); + return; + } + console.log("Buttons slide out animations completed!"); + + animations = new Array(); + animations.push({ target: panel1, property: animation.Properties.scale, value: { x: 0, y: 0 }, duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + animations.push({ target: panel1, property: animation.Properties.rotate, value: 1080, duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + animations.push({ target: panel1, property: animation.Properties.backgroundColor, value: new colorModule.Color("red"), duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + configureAnimationCurve(animations, true); + + cancelToken = animation.start(animations, vm.playSequentially,(cancelled?: boolean) => { + if (cancelled) { + console.log("Panel animation cancelled"); + return; + } + console.log("Panel animation completed!"); + }); + }); +} + +export function onSlideIn(args: observable.EventData) { + var animations: Array; + + animations = new Array(); + animations.push({ target: panel1, property: animation.Properties.scale, value: { x: 1, y: 1 }, duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + animations.push({ target: panel1, property: animation.Properties.rotate, value: 0, duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + animations.push({ target: panel1, property: animation.Properties.backgroundColor, value: new colorModule.Color("yellow"), duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + configureAnimationCurve(animations, false); + + cancelToken = animation.start(animations, vm.playSequentially,(cancelled?: boolean) => { + if (cancelled) { + console.log("Panel animation cancelled"); + return; + } + console.log("Panel animation completed!"); + + animations = new Array(); + animations.push({ target: button1, property: animation.Properties.translate, value: { x: 0, y: 0 }, duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + animations.push({ target: button1, property: animation.Properties.scale, value: { x: 1, y: 1 }, duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + animations.push({ target: button1, property: animation.Properties.opacity, value: 1, duration: vm.duration, delay: 0, repeatCount: vm.repeatCount }); + + animations.push({ target: button2, property: animation.Properties.translate, value: { x: 0, y: 0 }, duration: vm.duration, delay: vm.duration, repeatCount: vm.repeatCount }); + animations.push({ target: button2, property: animation.Properties.scale, value: { x: 1, y: 1 }, duration: vm.duration, delay: vm.duration, repeatCount: vm.repeatCount }); + animations.push({ target: button2, property: animation.Properties.opacity, value: 1, duration: vm.duration, delay: vm.duration, repeatCount: vm.repeatCount }); + + animations.push({ target: button3, property: animation.Properties.translate, value: { x: 0, y: 0 }, duration: vm.duration, delay: vm.duration * 2, repeatCount: vm.repeatCount }); + animations.push({ target: button3, property: animation.Properties.scale, value: { x: 1, y: 1 }, duration: vm.duration, delay: vm.duration * 2, repeatCount: vm.repeatCount }); + animations.push({ target: button3, property: animation.Properties.opacity, value: 1, duration: vm.duration, delay: vm.duration * 2, repeatCount: vm.repeatCount }); + + configureAnimationCurve(animations, false); + + cancelToken = animation.start(animations, vm.playSequentially,(cancelled?: boolean) => { + if (cancelled) { + console.log("Buttons slide in animations cancelled"); + return; + } + console.log("Buttons slide in animations completed!"); + }); + }); +} + +function configureAnimationCurve(animations: Array, slideOut: boolean) { + var i = 0; + var length = animations.length; + if (page.android) { + var interpolator = slideOut ? new android.view.animation.AccelerateInterpolator(1) : new android.view.animation.DecelerateInterpolator(1); + for (; i < length; i++) { + animations[i].androidInterpolator = interpolator; + } + } + else { + for (; i < length; i++) { + animations[i].iosUIViewAnimationCurve = slideOut ? UIViewAnimationCurve.UIViewAnimationCurveEaseIn : UIViewAnimationCurve.UIViewAnimationCurveEaseOut; + } + } +} + +export function onStop(args: observable.EventData) { + cancelToken.cancel(); +} + +export function onTap(args: observable.EventData) { + console.log((args.object).text); +} \ 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..1e2ee8387 --- /dev/null +++ b/apps/animations/main-page.xml @@ -0,0 +1,29 @@ + + + + +