From d030d9e136d981f38c6da112f23324b6f68c6ae1 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Tue, 23 Jun 2015 09:49:39 -0500 Subject: [PATCH] overlay dispose fixes --- ionic/components/modal/test/basic/index.js | 74 ++++++++++------------ ionic/components/overlay/overlay.js | 7 +- 2 files changed, 38 insertions(+), 43 deletions(-) diff --git a/ionic/components/modal/test/basic/index.js b/ionic/components/modal/test/basic/index.js index bc2160698e..384999342e 100644 --- a/ionic/components/modal/test/basic/index.js +++ b/ionic/components/modal/test/basic/index.js @@ -10,31 +10,6 @@ import {IonicComponent} from 'ionic/ionic'; import {Modal, NavController, NavParams, Animation, ActionMenu} from 'ionic/ionic'; -class FadeIn extends Animation { - constructor(element) { - super(element); - this - .easing('ease') - .duration(450) - .fadeIn(); - } -} - -Animation.register('my-fade-in', FadeIn); - -class FadeOut extends Animation { - constructor(element) { - super(element); - this - .easing('ease') - .duration(250) - .fadeOut(); - } -} - -Animation.register('my-fade-out', FadeOut); - - @Component({ selector: 'ion-app', appInjector: [Modal] @@ -71,7 +46,10 @@ export class ContactModal extends Modal { @Component({ selector: 'ion-view', - appInjector: [Modal] + appInjector: [ + Modal, + ActionMenu + ] }) @IonicView({ template: ` @@ -95,11 +73,13 @@ export class ContactModal extends Modal { export class ModalFirstPage { constructor( nav: NavController, - Modal: Modal + Modal: Modal, + ActionMenu: ActionMenu ) { this.nav = nav; this.val = Math.round(Math.random() * 8999) + 1000; this.Modal = Modal; + this.ActionMenu = ActionMenu; } push() { @@ -112,12 +92,12 @@ export class ModalFirstPage { } closeByHandeModal() { - let modal = Modal.getByHandle('my-awesome-modal'); + let modal = this.Modal.getByHandle('my-awesome-modal'); modal.close(); } openActionMenu() { - ActionMenu.open({ + this.ActionMenu.open({ buttons: [ { text: 'Share This' }, { text: 'Move' } @@ -146,20 +126,12 @@ export class ModalFirstPage { @IonicView({ template: ` Second Page Header - -

- -

- -

- -
` }) @@ -174,9 +146,6 @@ export class ModalSecondPage { console.log('Second page params:', params); } - push() { - } - } export function main(ionicBootstrap) { @@ -188,3 +157,28 @@ export function main(ionicBootstrap) { console.log('ionicBootstrap', app); }); } + + +class FadeIn extends Animation { + constructor(element) { + super(element); + this + .easing('ease') + .duration(450) + .fadeIn(); + } +} + +Animation.register('my-fade-in', FadeIn); + +class FadeOut extends Animation { + constructor(element) { + super(element); + this + .easing('ease') + .duration(250) + .fadeOut(); + } +} + +Animation.register('my-fade-out', FadeOut); diff --git a/ionic/components/overlay/overlay.js b/ionic/components/overlay/overlay.js index 71f6d8476d..80492e7332 100644 --- a/ionic/components/overlay/overlay.js +++ b/ionic/components/overlay/overlay.js @@ -20,6 +20,7 @@ export class Overlay { app.appendComponent(ComponentType).then(ref => { let overlay = ref.instance; + overlay._dispose = ref.dispose; overlay.setApp(app); overlay._type = overlayType; overlay._handle = opts && opts.handle; @@ -70,7 +71,7 @@ export class Overlay { ClickBlock(true, leavingAnimation.duration() + 200); leavingAnimation.play().then(() => { - this._dispose(); + this.dispose(); ClickBlock(false); leavingAnimation.dispose(); resolve(); @@ -105,8 +106,8 @@ export class Overlay { util.extend(this.options, opts); } - _dispose() { - this.dispose && this.dispose(); + dispose() { + this._dispose && this._dispose(); if (this.app) { util.array.remove(this.app.overlays, this); }