mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
feat(modals): mode transitions
This commit is contained in:
@ -12,11 +12,11 @@ import * as util from 'ionic/util';
|
|||||||
* @usage
|
* @usage
|
||||||
* ```ts
|
* ```ts
|
||||||
* class MyApp {
|
* class MyApp {
|
||||||
*
|
*
|
||||||
* constructor(modal: Modal, app: IonicApp, ionicConfig: IonicConfig) {
|
* constructor(modal: Modal, app: IonicApp, ionicConfig: IonicConfig) {
|
||||||
* this.modal = modal;
|
* this.modal = modal;
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* openModal() {
|
* openModal() {
|
||||||
* this.modal.open(ContactModal, {
|
* this.modal.open(ContactModal, {
|
||||||
* enterAnimation: 'my-fade-in',
|
* enterAnimation: 'my-fade-in',
|
||||||
@ -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);
|
||||||
|
@ -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',
|
||||||
|
@ -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>
|
||||||
|
|
||||||
|
@ -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',
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user