mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-19 03:32:21 +08:00
63 lines
1.2 KiB
JavaScript
63 lines
1.2 KiB
JavaScript
import {Overlay} from '../overlay/overlay';
|
|
import {Animation} from '../../animations/animation';
|
|
|
|
|
|
export class Modal extends Overlay {
|
|
|
|
static get config() {
|
|
return {
|
|
selector: 'ion-modal',
|
|
hostProperties: {
|
|
'zIndex': 'style.z-index'
|
|
}
|
|
}
|
|
}
|
|
|
|
constructor() {
|
|
super();
|
|
this.extendOptions({
|
|
enterAnimation: 'modal-slide-in',
|
|
leaveAnimation: 'modal-slide-out'
|
|
});
|
|
}
|
|
|
|
/* Static Methods */
|
|
static open(ComponentType: Type, opts) {
|
|
return this.create(overlayType, ComponentType, opts);
|
|
}
|
|
|
|
static get() {
|
|
return Modal.getByType(overlayType);
|
|
}
|
|
|
|
}
|
|
|
|
const overlayType = 'modal';
|
|
|
|
|
|
/**
|
|
* Animations for modals
|
|
*/
|
|
class ModalSlideIn extends Animation {
|
|
constructor(element) {
|
|
super(element);
|
|
this
|
|
.easing('cubic-bezier(.36,.66,.04,1)')
|
|
.duration(400)
|
|
.fromTo('translateY', '100%', '0%');
|
|
}
|
|
}
|
|
Animation.register('modal-slide-in', ModalSlideIn);
|
|
|
|
|
|
class ModalSlideOut extends Animation {
|
|
constructor(element) {
|
|
super(element);
|
|
this
|
|
.easing('ease-out')
|
|
.duration(250)
|
|
.fromTo('translateY', '0%', '100%');
|
|
}
|
|
}
|
|
Animation.register('modal-slide-out', ModalSlideOut);
|