From 4f0fded520094b851828051484e11650d0dce828 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 14 May 2015 14:45:41 -0500 Subject: [PATCH] init iOS toolbar animations --- ionic/components/toolbar/toolbar.js | 12 ++----- ionic/transitions/ios-transition.js | 56 +++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 21 deletions(-) diff --git a/ionic/components/toolbar/toolbar.js b/ionic/components/toolbar/toolbar.js index 7b099c199f..a38eff67a6 100644 --- a/ionic/components/toolbar/toolbar.js +++ b/ionic/components/toolbar/toolbar.js @@ -10,10 +10,7 @@ import {Platform} from 'ionic/platform/platform'; @Component({ - selector: 'ion-toolbar', - hostProperties: { - toolbarId: 'className' - } + selector: 'ion-toolbar' }) @View({ template: ` @@ -34,12 +31,7 @@ import {Platform} from 'ionic/platform/platform'; `, directives: [ToolbarTitle] }) -export class Toolbar { - constructor(navItem: NavItem, elementRef: ElementRef) { - this.toolbarId = 'toolbar-id-' + navItem.id; - console.log('Toolbar constructor', this.toolbarId) - } -} +export class Toolbar {} @Component({ diff --git a/ionic/transitions/ios-transition.js b/ionic/transitions/ios-transition.js index d35efd49b6..961dcd79b8 100644 --- a/ionic/transitions/ios-transition.js +++ b/ionic/transitions/ios-transition.js @@ -27,23 +27,40 @@ class IOSTransition extends Animation { this.enteringItem = navCtrl.getStagedEnteringItem(); this.leavingItem = navCtrl.getStagedLeavingItem(); - // create animation for the entering item - let enteringItemAnimation = new Animation(this.enteringItem.getContent()); + // create animation for the entering content + let enteringContent = new Animation(this.enteringItem.getContent()); - // create animation for the leaving item + // create animation for the entering toolbars + let enteringToolbars = new Animation(this.enteringItem.getToolbars()); + + // create animation for the leaving content // leavingItem could be null, but the animation instance knows to do nothing - let leavingItemAnimation = new Animation(this.leavingItem && this.leavingItem.getContent()); + let leavingContent = new Animation(this.leavingItem && this.leavingItem.getContent()); + + // create animation for the leaving content + // leavingItem could be null, but the animation instance knows to do nothing + let leavingToolbars = new Animation(this.leavingItem && this.leavingItem.getToolbars()); // entering item moves to center // before starting, set enteringItem to display: block - enteringItemAnimation + enteringContent + .display('block') + .to(TRANSLATE_X, 0) + .to(OPACITY, 1); + + enteringToolbars .display('block') .to(TRANSLATE_X, 0) .to(OPACITY, 1); // leaving view moves off screen // when completed, set leavingItem to display: none - leavingItemAnimation + leavingContent + .from(TRANSLATE_X, 0) + .from(OPACITY, 1) + .display('none'); + + leavingToolbars .from(TRANSLATE_X, 0) .from(OPACITY, 1) .display('none'); @@ -51,28 +68,45 @@ class IOSTransition extends Animation { // set properties depending on direction if (opts.direction === 'back') { // back direction - enteringItemAnimation + enteringContent .from(TRANSLATE_X, OFF_LEFT) .from(OPACITY, OFF_OPACITY) .to(OPACITY, 1); - leavingItemAnimation + enteringToolbars + .from(TRANSLATE_X, OFF_LEFT) + .from(OPACITY, OFF_OPACITY) + .to(OPACITY, 1); + + leavingContent + .to(TRANSLATE_X, OFF_RIGHT) + .to(OPACITY, 1); + + leavingToolbars .to(TRANSLATE_X, OFF_RIGHT) .to(OPACITY, 1); } else { // forward direction - enteringItemAnimation + enteringContent .from(TRANSLATE_X, OFF_RIGHT) .from(OPACITY, 1); - leavingItemAnimation + enteringToolbars + .from(TRANSLATE_X, OFF_RIGHT) + .from(OPACITY, 1); + + leavingContent + .to(TRANSLATE_X, OFF_LEFT) + .to(OPACITY, OFF_OPACITY); + + leavingToolbars .to(TRANSLATE_X, OFF_LEFT) .to(OPACITY, OFF_OPACITY); } // set child animations - this.setChildren([enteringItemAnimation, leavingItemAnimation]); + this.setChildren([enteringContent, enteringToolbars, leavingContent, leavingToolbars]); } stage() {