From c7e7fc4151ed90e9f037251a0b26cd84940be239 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Tue, 7 Jul 2015 10:25:42 -0500 Subject: [PATCH] Animation sink --- ionic/components/app/test/sink/index.ts | 2 + .../app/test/sink/pages/animation.ts | 140 ++++++++++++++++++ ionic/components/progress/progress.scss | 0 3 files changed, 142 insertions(+) create mode 100644 ionic/components/app/test/sink/pages/animation.ts delete mode 100644 ionic/components/progress/progress.scss diff --git a/ionic/components/app/test/sink/index.ts b/ionic/components/app/test/sink/index.ts index 90ea4fef4b..da3c5bffe9 100644 --- a/ionic/components/app/test/sink/index.ts +++ b/ionic/components/app/test/sink/index.ts @@ -13,6 +13,7 @@ import {TableSearchPage} from './pages/table-search' import {IconsPage} from './pages/ionicons' import {TabsPage} from './pages/tabs' import {AsidePage} from './pages/aside' +import {AnimationPage} from './pages/animation' import {SlidePage} from './pages/slides' import {ActionMenuPage} from './pages/action-menu' import {ModalPage} from './pages/modal' @@ -41,6 +42,7 @@ class MyApp { { title: 'Icons', component: IconsPage }, { title: 'Tabs', component: TabsPage }, { title: 'Aside', component: AsidePage }, + { title: 'Animation', component: AnimationPage }, { title: 'Slides', component: SlidePage}, { title: 'Action Menu', component: ActionMenuPage }, { title: 'Modal', component: ModalPage } diff --git a/ionic/components/app/test/sink/pages/animation.ts b/ionic/components/app/test/sink/pages/animation.ts new file mode 100644 index 0000000000..e3e0b5cea4 --- /dev/null +++ b/ionic/components/app/test/sink/pages/animation.ts @@ -0,0 +1,140 @@ +import {Component, Directive, View} from 'angular2/angular2'; + +import {Animation, IonicApp, List, Item, ActionMenu, Modal, ModalRef, + NavbarTemplate, Navbar, NavController, Content} from 'ionic/ionic'; + +import {SinkPage} from '../sink-page'; + +let opacity = 0.2; +let rotateZ = '180deg'; +let translateX = '100px'; +let scale = 0.6; + + +@Component({ + selector: 'ion-view' +}) +@View({ + template: ` + Animation + + + + + +

Animation

+

+ Ionic comes with a powerful Animation library based on the emerging Web Animation API. Trigger + animations based on user actions, step (or "scrub") through during a drag gesture, or add + realistic physics effects to your app. The Animation API is a major improvement over CSS animations. +

+

+ + +

+
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+
+
+ +
+ +

+ +

+ +
+ `, + directives: [NavbarTemplate, Navbar, Content, List, Item] +}) +export class AnimationPage extends SinkPage { + constructor(app: IonicApp) { + super(app); + + this.animation = new Animation(); + + this.animation + .duration(2000) + .easing('spring', { damping: 6, elasticity: 10 }); + + + var ball = new Animation( document.querySelector('.ball') ); + ball + .from('translateX', '0px') + .to('translateX', '250px') + + this.animation.add(ball); + + + var row1 = new Animation( document.querySelectorAll('.square') ); + row1 + .from('opacity', 0.8) + .to('opacity', 0.2) + + this.animation.add(row1); + + var row2 = new Animation( document.querySelectorAll('.square2') ); + row2 + .from('rotate', '0deg') + .from('scale', '1') + .to('rotate', '90deg') + .to('scale', '0.5') + .before.addClass('added-before-play') + .after.addClass('added-after-finish') + + this.animation.add(row1, row2); + + this.animation.onReady(animation => { + console.log('onReady', animation); + }); + + this.animation.onPlay(animation => { + console.log('onPlay', animation); + }); + + this.animation.onFinish(animation => { + console.log('onFinish', animation); + }); + + } + + play() { + this.animation.play(); + } + + pause() { + this.animation.pause(); + } + + progress(ev) { + this.animation.progress( parseFloat(ev.srcElement.value) ); + } +} diff --git a/ionic/components/progress/progress.scss b/ionic/components/progress/progress.scss deleted file mode 100644 index e69de29bb2..0000000000