mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 21:15:24 +08:00
docs(overlay): onDidDismiss
This commit is contained in:
@ -137,7 +137,7 @@ export class ActionSheet implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
present(): Promise<void> {
|
present(): Promise<void> {
|
||||||
return present(this, 'actionSheetEnter', iosEnterAnimation, mdEnterAnimation, undefined);
|
return present(this, 'actionSheetEnter', iosEnterAnimation, mdEnterAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,16 +145,32 @@ export class ActionSheet implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
dismiss(data?: any, role?: string): Promise<void> {
|
dismiss(data?: any, role?: string): Promise<void> {
|
||||||
return dismiss(this, data, role, 'actionSheetLeave', iosLeaveAnimation, mdLeaveAnimation, undefined);
|
return dismiss(this, data, role, 'actionSheetLeave', iosLeaveAnimation, mdLeaveAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the action-sheet did dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await actionSheet.onDidDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onDidDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onDidDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionActionSheetDidDismiss', callback);
|
return eventMethod(this.el, 'ionActionSheetDidDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the action-sheet will dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await actionSheet.onWillDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onWillDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onWillDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionActionSheetWillDismiss', callback);
|
return eventMethod(this.el, 'ionActionSheetWillDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ export class Alert implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
present(): Promise<void> {
|
present(): Promise<void> {
|
||||||
return present(this, 'alertEnter', iosEnterAnimation, mdEnterAnimation, undefined).then(() => {
|
return present(this, 'alertEnter', iosEnterAnimation, mdEnterAnimation).then(() => {
|
||||||
autoFocus(this.el);
|
autoFocus(this.el);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -160,16 +160,32 @@ export class Alert implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
dismiss(data?: any, role?: string): Promise<void> {
|
dismiss(data?: any, role?: string): Promise<void> {
|
||||||
return dismiss(this, data, role, 'alertLeave', iosLeaveAnimation, mdLeaveAnimation, undefined);
|
return dismiss(this, data, role, 'alertLeave', iosLeaveAnimation, mdLeaveAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the alert did dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await alert.onDidDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onDidDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onDidDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionAlerDidDismiss', callback);
|
return eventMethod(this.el, 'ionAlerDidDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the alert will dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await alert.onWillDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onWillDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onWillDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionAlertWillDismiss', callback);
|
return eventMethod(this.el, 'ionAlertWillDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,16 +159,32 @@ export class Loading implements OverlayInterface {
|
|||||||
if (this.durationTimeout) {
|
if (this.durationTimeout) {
|
||||||
clearTimeout(this.durationTimeout);
|
clearTimeout(this.durationTimeout);
|
||||||
}
|
}
|
||||||
return dismiss(this, data, role, 'loadingLeave', iosLeaveAnimation, mdLeaveAnimation, undefined);
|
return dismiss(this, data, role, 'loadingLeave', iosLeaveAnimation, mdLeaveAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the loading did dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await loading.onDidDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onDidDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onDidDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionLoadingDidDismiss', callback);
|
return eventMethod(this.el, 'ionLoadingDidDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the loading will dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await loading.onWillDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onWillDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onWillDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionLoadingWillDismiss', callback);
|
return eventMethod(this.el, 'ionLoadingWillDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ export class Modal implements OverlayInterface {
|
|||||||
};
|
};
|
||||||
return attachComponent(this.delegate, container, this.component, classes, data)
|
return attachComponent(this.delegate, container, this.component, classes, data)
|
||||||
.then(el => this.usersElement = el)
|
.then(el => this.usersElement = el)
|
||||||
.then(() => present(this, 'modalEnter', iosEnterAnimation, mdEnterAnimation, undefined));
|
.then(() => present(this, 'modalEnter', iosEnterAnimation, mdEnterAnimation));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -185,16 +185,32 @@ export class Modal implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
dismiss(data?: any, role?: string): Promise<void> {
|
dismiss(data?: any, role?: string): Promise<void> {
|
||||||
return dismiss(this, data, role, 'modalLeave', iosLeaveAnimation, mdLeaveAnimation, undefined);
|
return dismiss(this, data, role, 'modalLeave', iosLeaveAnimation, mdLeaveAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the modal did dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await modal.onDidDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onDidDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onDidDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionModalDidDismiss', callback);
|
return eventMethod(this.el, 'ionModalDidDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the modal will dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await modal.onWillDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onWillDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onWillDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionModalWillDismiss', callback);
|
return eventMethod(this.el, 'ionModalWillDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,16 +164,32 @@ export class Picker implements OverlayInterface {
|
|||||||
if (this.durationTimeout) {
|
if (this.durationTimeout) {
|
||||||
clearTimeout(this.durationTimeout);
|
clearTimeout(this.durationTimeout);
|
||||||
}
|
}
|
||||||
return dismiss(this, data, role, 'pickerLeave', iosLeaveAnimation, iosLeaveAnimation, undefined);
|
return dismiss(this, data, role, 'pickerLeave', iosLeaveAnimation, iosLeaveAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the picker did dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await picker.onDidDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onDidDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onDidDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionPickerDidDismiss', callback);
|
return eventMethod(this.el, 'ionPickerDidDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the picker will dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await picker.onWillDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onWillDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onWillDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionPickerWillDismiss', callback);
|
return eventMethod(this.el, 'ionPickerWillDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,13 +198,29 @@ export class Popover implements OverlayInterface {
|
|||||||
return dismiss(this, data, role, 'popoverLeave', iosLeaveAnimation, mdLeaveAnimation, this.ev);
|
return dismiss(this, data, role, 'popoverLeave', iosLeaveAnimation, mdLeaveAnimation, this.ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the popover did dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await popover.onDidDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onDidDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onDidDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionPopoverDidDismiss', callback);
|
return eventMethod(this.el, 'ionPopoverDidDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the popover will dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await popover.onWillDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onWillDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onWillDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionPopoverWillDismiss', callback);
|
return eventMethod(this.el, 'ionPopoverWillDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,13 +157,29 @@ export class Toast implements OverlayInterface {
|
|||||||
return dismiss(this, data, role, 'toastLeave', iosLeaveAnimation, mdLeaveAnimation, this.position);
|
return dismiss(this, data, role, 'toastLeave', iosLeaveAnimation, mdLeaveAnimation, this.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the toast did dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await toast.onDidDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onDidDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onDidDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionToastDidDismiss', callback);
|
return eventMethod(this.el, 'ionToastDidDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a promise that resolves when the toast will dismiss. It also accepts a callback
|
||||||
|
* that is called in the same circustances.
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* const {data, role} = await toast.onWillDismiss();
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
onWillDismiss(callback: (data?: any, role?: string) => void): Promise<OverlayEventDetail> {
|
onWillDismiss(callback?: (detail: OverlayEventDetail) => void): Promise<OverlayEventDetail> {
|
||||||
return eventMethod(this.el, 'ionToastWillDismiss', callback);
|
return eventMethod(this.el, 'ionToastWillDismiss', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ export function present(
|
|||||||
name: string,
|
name: string,
|
||||||
iosEnterAnimation: AnimationBuilder,
|
iosEnterAnimation: AnimationBuilder,
|
||||||
mdEnterAnimation: AnimationBuilder,
|
mdEnterAnimation: AnimationBuilder,
|
||||||
opts: any
|
opts?: any
|
||||||
) {
|
) {
|
||||||
if (overlay.presented) {
|
if (overlay.presented) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
@ -83,7 +83,7 @@ export function dismiss(
|
|||||||
name: string,
|
name: string,
|
||||||
iosLeaveAnimation: AnimationBuilder,
|
iosLeaveAnimation: AnimationBuilder,
|
||||||
mdLeaveAnimation: AnimationBuilder,
|
mdLeaveAnimation: AnimationBuilder,
|
||||||
opts: any
|
opts?: any
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (!overlay.presented) {
|
if (!overlay.presented) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
@ -151,9 +151,9 @@ export function attachComponent(delegate: FrameworkDelegate, container: Element,
|
|||||||
return Promise.resolve(el);
|
return Promise.resolve(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function eventMethod(element: HTMLElement, eventName: string, callback: Function): Promise<any> {
|
export function eventMethod<T>(element: HTMLElement, eventName: string, callback?: (detail: T) => void): Promise<T> {
|
||||||
let resolve: Function;
|
let resolve: Function;
|
||||||
const promise = new Promise(r => resolve = r);
|
const promise = new Promise<T>(r => resolve = r);
|
||||||
onceEvent(element, eventName, (event) => {
|
onceEvent(element, eventName, (event) => {
|
||||||
const detail = event.detail;
|
const detail = event.detail;
|
||||||
callback && callback(detail);
|
callback && callback(detail);
|
||||||
|
Reference in New Issue
Block a user