mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-22 21:48:42 +08:00
fix(overlays): prevent dismissing an overlay twice
This commit is contained in:
@ -37,6 +37,7 @@
|
|||||||
"deploy": "np --any-branch",
|
"deploy": "np --any-branch",
|
||||||
"version": "npm run clean && stencil build --docs",
|
"version": "npm run clean && stencil build --docs",
|
||||||
"dev": "sd concurrent \"stencil build --dev --watch --docs\" \"stencil-dev-server\"",
|
"dev": "sd concurrent \"stencil build --dev --watch --docs\" \"stencil-dev-server\"",
|
||||||
|
"devapp": "sd concurrent \"stencil build --dev --watch --docs\" \"stencil-dev-server --broadcast\"",
|
||||||
"e2e": "node ./scripts/e2e",
|
"e2e": "node ./scripts/e2e",
|
||||||
"e2e-debug": "node --inspect --debug-brk ./scripts/e2e",
|
"e2e-debug": "node --inspect --debug-brk ./scripts/e2e",
|
||||||
"lint": "npm run tslint & npm run sass-lint",
|
"lint": "npm run tslint & npm run sass-lint",
|
||||||
|
@ -26,6 +26,7 @@ export class ActionSheet implements OverlayInterface {
|
|||||||
mode: string;
|
mode: string;
|
||||||
color: string;
|
color: string;
|
||||||
|
|
||||||
|
private presented = false;
|
||||||
private animation: Animation | null = null;
|
private animation: Animation | null = null;
|
||||||
|
|
||||||
@Element() private el: HTMLElement;
|
@Element() private el: HTMLElement;
|
||||||
@ -137,7 +138,12 @@ export class ActionSheet implements OverlayInterface {
|
|||||||
* Present the action sheet overlay after it has been created.
|
* Present the action sheet overlay after it has been created.
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
present() {
|
present(): Promise<void> {
|
||||||
|
if(this.presented) {
|
||||||
|
return Promise.reject('overlay already presented');
|
||||||
|
}
|
||||||
|
this.presented = true;
|
||||||
|
|
||||||
this.ionActionSheetWillPresent.emit();
|
this.ionActionSheetWillPresent.emit();
|
||||||
|
|
||||||
this.el.style.zIndex = `${20000 + this.overlayId}`;
|
this.el.style.zIndex = `${20000 + this.overlayId}`;
|
||||||
@ -156,6 +162,11 @@ export class ActionSheet implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
dismiss(data?: any, role?: string) {
|
dismiss(data?: any, role?: string) {
|
||||||
|
if(!this.presented) {
|
||||||
|
return Promise.reject('overlay is not presented');
|
||||||
|
}
|
||||||
|
this.presented = false;
|
||||||
|
|
||||||
this.ionActionSheetWillDismiss.emit({data, role});
|
this.ionActionSheetWillDismiss.emit({data, role});
|
||||||
|
|
||||||
const animationBuilder = this.leaveAnimation || this.config.get('actionSheetLeave', this.mode === 'ios' ? iosLeaveAnimation : mdLeaveAnimation);
|
const animationBuilder = this.leaveAnimation || this.config.get('actionSheetLeave', this.mode === 'ios' ? iosLeaveAnimation : mdLeaveAnimation);
|
||||||
|
@ -24,6 +24,7 @@ export class Alert implements OverlayInterface {
|
|||||||
mode: string;
|
mode: string;
|
||||||
color: string;
|
color: string;
|
||||||
|
|
||||||
|
private presented = false;
|
||||||
private animation: Animation | null = null;
|
private animation: Animation | null = null;
|
||||||
private activeId: string;
|
private activeId: string;
|
||||||
private inputType: string | null = null;
|
private inputType: string | null = null;
|
||||||
@ -143,7 +144,11 @@ export class Alert implements OverlayInterface {
|
|||||||
* Present the alert overlay after it has been created.
|
* Present the alert overlay after it has been created.
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
present() {
|
present(): Promise<void> {
|
||||||
|
if(this.presented) {
|
||||||
|
return Promise.reject('overlay already presented');
|
||||||
|
}
|
||||||
|
this.presented = true;
|
||||||
this.ionAlertWillPresent.emit();
|
this.ionAlertWillPresent.emit();
|
||||||
|
|
||||||
this.el.style.zIndex = `${20000 + this.overlayId}`;
|
this.el.style.zIndex = `${20000 + this.overlayId}`;
|
||||||
@ -166,6 +171,10 @@ export class Alert implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
dismiss(data?: any, role?: string) {
|
dismiss(data?: any, role?: string) {
|
||||||
|
if(!this.presented) {
|
||||||
|
return Promise.reject('overlay is not presented');
|
||||||
|
}
|
||||||
|
this.presented = false;
|
||||||
this.ionAlertWillDismiss.emit({data, role});
|
this.ionAlertWillDismiss.emit({data, role});
|
||||||
|
|
||||||
// get the user's animation fn if one was provided
|
// get the user's animation fn if one was provided
|
||||||
|
@ -24,6 +24,7 @@ export class Loading implements OverlayInterface {
|
|||||||
color: string;
|
color: string;
|
||||||
mode: string;
|
mode: string;
|
||||||
|
|
||||||
|
private presented = false;
|
||||||
private animation: Animation;
|
private animation: Animation;
|
||||||
private durationTimeout: any;
|
private durationTimeout: any;
|
||||||
|
|
||||||
@ -162,7 +163,11 @@ export class Loading implements OverlayInterface {
|
|||||||
* Present the loading overlay after it has been created.
|
* Present the loading overlay after it has been created.
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
present() {
|
present(): Promise<void> {
|
||||||
|
if(this.presented) {
|
||||||
|
return Promise.reject('overlay already presented');
|
||||||
|
}
|
||||||
|
this.presented = true;
|
||||||
this.ionLoadingWillPresent.emit();
|
this.ionLoadingWillPresent.emit();
|
||||||
|
|
||||||
this.el.style.zIndex = `${20000 + this.overlayId}`;
|
this.el.style.zIndex = `${20000 + this.overlayId}`;
|
||||||
@ -181,6 +186,10 @@ export class Loading implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
dismiss(data?: any, role?: string) {
|
dismiss(data?: any, role?: string) {
|
||||||
|
if(!this.presented) {
|
||||||
|
return Promise.reject('overlay is not presented');
|
||||||
|
}
|
||||||
|
this.presented = false;
|
||||||
clearTimeout(this.durationTimeout);
|
clearTimeout(this.durationTimeout);
|
||||||
|
|
||||||
this.ionLoadingWillDismiss.emit({data, role});
|
this.ionLoadingWillDismiss.emit({data, role});
|
||||||
|
@ -24,6 +24,7 @@ import mdLeaveAnimation from './animations/md.leave';
|
|||||||
})
|
})
|
||||||
export class Modal implements OverlayInterface {
|
export class Modal implements OverlayInterface {
|
||||||
|
|
||||||
|
private presented = false;
|
||||||
private animation: Animation;
|
private animation: Animation;
|
||||||
private usersComponentElement: HTMLElement;
|
private usersComponentElement: HTMLElement;
|
||||||
|
|
||||||
@ -145,7 +146,12 @@ export class Modal implements OverlayInterface {
|
|||||||
* Present the modal overlay after it has been created.
|
* Present the modal overlay after it has been created.
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
present() {
|
present(): Promise<void> {
|
||||||
|
if(this.presented) {
|
||||||
|
return Promise.reject('overlay already presented');
|
||||||
|
}
|
||||||
|
this.presented = true;
|
||||||
|
|
||||||
if (this.animation) {
|
if (this.animation) {
|
||||||
this.animation.destroy();
|
this.animation.destroy();
|
||||||
this.animation = null;
|
this.animation = null;
|
||||||
@ -193,6 +199,10 @@ export class Modal implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
dismiss(data?: any, role?: string) {
|
dismiss(data?: any, role?: string) {
|
||||||
|
if(!this.presented) {
|
||||||
|
return Promise.reject('overlay is not presented');
|
||||||
|
}
|
||||||
|
this.presented = false;
|
||||||
if (this.animation) {
|
if (this.animation) {
|
||||||
this.animation.destroy();
|
this.animation.destroy();
|
||||||
this.animation = null;
|
this.animation = null;
|
||||||
|
@ -20,6 +20,7 @@ import iosLeaveAnimation from './animations/ios.leave';
|
|||||||
})
|
})
|
||||||
export class Picker implements OverlayInterface {
|
export class Picker implements OverlayInterface {
|
||||||
|
|
||||||
|
private presented = false;
|
||||||
private animation: Animation;
|
private animation: Animation;
|
||||||
private durationTimeout: any;
|
private durationTimeout: any;
|
||||||
private mode: string;
|
private mode: string;
|
||||||
@ -114,7 +115,12 @@ export class Picker implements OverlayInterface {
|
|||||||
* Present the picker overlay after it has been created.
|
* Present the picker overlay after it has been created.
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
present() {
|
present(): Promise<void> {
|
||||||
|
if(this.presented) {
|
||||||
|
return Promise.reject('overlay already presented');
|
||||||
|
}
|
||||||
|
this.presented = true;
|
||||||
|
|
||||||
if (this.animation) {
|
if (this.animation) {
|
||||||
this.animation.destroy();
|
this.animation.destroy();
|
||||||
this.animation = null;
|
this.animation = null;
|
||||||
@ -147,6 +153,10 @@ export class Picker implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
dismiss(data?: any, role?: string) {
|
dismiss(data?: any, role?: string) {
|
||||||
|
if(!this.presented) {
|
||||||
|
return Promise.reject('overlay is not presented');
|
||||||
|
}
|
||||||
|
this.presented = false;
|
||||||
clearTimeout(this.durationTimeout);
|
clearTimeout(this.durationTimeout);
|
||||||
|
|
||||||
if (this.animation) {
|
if (this.animation) {
|
||||||
|
@ -23,6 +23,7 @@ import mdLeaveAnimation from './animations/md.leave';
|
|||||||
})
|
})
|
||||||
export class Popover implements OverlayInterface {
|
export class Popover implements OverlayInterface {
|
||||||
|
|
||||||
|
private presented = false;
|
||||||
private animation: Animation;
|
private animation: Animation;
|
||||||
private usersComponentElement: HTMLElement;
|
private usersComponentElement: HTMLElement;
|
||||||
|
|
||||||
@ -158,7 +159,12 @@ export class Popover implements OverlayInterface {
|
|||||||
* Present the popover overlay after it has been created.
|
* Present the popover overlay after it has been created.
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
present() {
|
present(): Promise<void> {
|
||||||
|
if(this.presented) {
|
||||||
|
return Promise.reject('overlay already presented');
|
||||||
|
}
|
||||||
|
this.presented = true;
|
||||||
|
|
||||||
if (this.animation) {
|
if (this.animation) {
|
||||||
this.animation.destroy();
|
this.animation.destroy();
|
||||||
this.animation = null;
|
this.animation = null;
|
||||||
@ -206,6 +212,10 @@ export class Popover implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
dismiss(data?: any, role?: string) {
|
dismiss(data?: any, role?: string) {
|
||||||
|
if(!this.presented) {
|
||||||
|
return Promise.reject('overlay is not presented');
|
||||||
|
}
|
||||||
|
this.presented = false;
|
||||||
if (this.animation) {
|
if (this.animation) {
|
||||||
this.animation.destroy();
|
this.animation.destroy();
|
||||||
this.animation = null;
|
this.animation = null;
|
||||||
|
@ -23,6 +23,7 @@ import mdLeaveAnimation from './animations/md.leave';
|
|||||||
})
|
})
|
||||||
export class Toast implements OverlayInterface {
|
export class Toast implements OverlayInterface {
|
||||||
|
|
||||||
|
private presented = false;
|
||||||
private animation: Animation | null;
|
private animation: Animation | null;
|
||||||
|
|
||||||
@Element() private el: HTMLElement;
|
@Element() private el: HTMLElement;
|
||||||
@ -126,7 +127,12 @@ export class Toast implements OverlayInterface {
|
|||||||
* Present the toast overlay after it has been created.
|
* Present the toast overlay after it has been created.
|
||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
present() {
|
present(): Promise<void> {
|
||||||
|
if(this.presented) {
|
||||||
|
return Promise.reject('overlay already presented');
|
||||||
|
}
|
||||||
|
this.presented = true;
|
||||||
|
|
||||||
if (this.animation) {
|
if (this.animation) {
|
||||||
this.animation.destroy();
|
this.animation.destroy();
|
||||||
this.animation = null;
|
this.animation = null;
|
||||||
@ -156,6 +162,11 @@ export class Toast implements OverlayInterface {
|
|||||||
*/
|
*/
|
||||||
@Method()
|
@Method()
|
||||||
dismiss(data?: any, role?: string) {
|
dismiss(data?: any, role?: string) {
|
||||||
|
if(!this.presented) {
|
||||||
|
return Promise.reject('overlay is not presented');
|
||||||
|
}
|
||||||
|
this.presented = false;
|
||||||
|
|
||||||
if (this.animation) {
|
if (this.animation) {
|
||||||
this.animation.destroy();
|
this.animation.destroy();
|
||||||
this.animation = null;
|
this.animation = null;
|
||||||
|
Reference in New Issue
Block a user