feat(modals): mode transitions

This commit is contained in:
Adam Bradley
2015-09-29 15:48:48 -05:00
parent ba08227c74
commit 6b07b86e8e
4 changed files with 48 additions and 6 deletions

View File

@ -38,8 +38,8 @@ export class Modal extends Overlay {
*/ */
open(ComponentType: Type, opts={}) { open(ComponentType: Type, opts={}) {
let defaults = { let defaults = {
enterAnimation: 'modal-slide-in', enterAnimation: this.config.setting('modalEnter') || 'modal-slide-in',
leaveAnimation: 'modal-slide-out', leaveAnimation: this.config.setting('modalLeave') || 'modal-slide-out',
}; };
return this.create(OVERLAY_TYPE, ComponentType, util.extend(defaults, opts)); return this.create(OVERLAY_TYPE, ComponentType, util.extend(defaults, opts));
@ -69,7 +69,7 @@ class ModalSlideIn extends Animation {
constructor(element) { constructor(element) {
super(element); super(element);
this this
.easing('cubic-bezier(.36,.66,.04,1)') .easing('cubic-bezier(0.36,0.66,0.04,1)')
.duration(400) .duration(400)
.fromTo('translateY', '100%', '0%'); .fromTo('translateY', '100%', '0%');
} }
@ -87,3 +87,29 @@ class ModalSlideOut extends Animation {
} }
} }
Animation.register('modal-slide-out', ModalSlideOut); Animation.register('modal-slide-out', ModalSlideOut);
class ModalMDSlideIn extends Animation {
constructor(element) {
super(element);
this
.easing('cubic-bezier(0.36,0.66,0.04,1)')
.duration(280)
.fromTo('translateY', '40px', '0px')
.fadeIn();
}
}
Animation.register('modal-md-slide-in', ModalMDSlideIn);
class ModalMDSlideOut extends Animation {
constructor(element) {
super(element);
this
.duration(200)
.easing('cubic-bezier(0.47,0,0.745,0.715)')
.fromTo('translateY', '0px', '40px')
.fadeOut();
}
}
Animation.register('modal-md-slide-out', ModalMDSlideOut);

View File

@ -33,6 +33,10 @@ class MyAppCmp {
} }
openModal() { openModal() {
this.modal.open(ContactModal);
}
openModalCustomAnimation() {
this.modal.open(ContactModal, { this.modal.open(ContactModal, {
enterAnimation: 'my-fade-in', enterAnimation: 'my-fade-in',
leaveAnimation: 'my-fade-out', leaveAnimation: 'my-fade-out',

View File

@ -1,3 +1,9 @@
<ion-content padding> <ion-content padding>
<button class="e2eOpenModal" (click)="openModal()">Open Modal</button> <button class="e2eOpenModal" (click)="openModal()">Modal: Default Animation</button>
</ion-content> </ion-content>
<ion-content padding>
<button (click)="openModalCustomAnimation()">Modal: Custom Animation</button>
</ion-content>

View File

@ -15,6 +15,9 @@ IonicConfig.modeConfig('ios', {
iconMode: 'ios', iconMode: 'ios',
modalEnter: 'modal-slide-in',
modalLeave: 'modal-slide-out',
tabBarPlacement: 'bottom', tabBarPlacement: 'bottom',
viewTransition: 'ios', viewTransition: 'ios',
@ -34,6 +37,9 @@ IonicConfig.modeConfig('md', {
iconMode: 'md', iconMode: 'md',
modalEnter: 'modal-md-slide-in',
modalLeave: 'modal-md-slide-out',
tabBarPlacement: 'top', tabBarPlacement: 'top',
viewTransition: 'md', viewTransition: 'md',