Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix modal bugs in #1144 #1147

Merged
merged 1 commit into from
Oct 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions components/modal/modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export class ModalDirective implements AfterViewInit, OnDestroy {
// reference to backdrop component
private backdrop: ComponentRef<ModalBackdropComponent>;

private timerHideModal: number = 0;
private timerRmBackDrop: number = 0;

private get document(): any {
return this.componentsHelper.getDocument();
};
Expand Down Expand Up @@ -107,6 +110,8 @@ export class ModalDirective implements AfterViewInit, OnDestroy {
this.isBodyOverflowing = void 0;
this.originalBodyPadding = void 0;
this.scrollbarWidth = void 0;
this.timerHideModal = void 0;
this.timerRmBackDrop = void 0;
}

public ngAfterViewInit(): any {
Expand All @@ -124,6 +129,8 @@ export class ModalDirective implements AfterViewInit, OnDestroy {
if (this._isShown) {
return;
}
clearTimeout(this.timerHideModal);
clearTimeout(this.timerRmBackDrop);

this._isShown = true;

Expand Down Expand Up @@ -151,12 +158,15 @@ export class ModalDirective implements AfterViewInit, OnDestroy {
return;
}

clearTimeout(this.timerHideModal);
clearTimeout(this.timerRmBackDrop);

this._isShown = false;
this.renderer.setElementClass(this.element.nativeElement, ClassName.IN, false);
// this._addClassIn = false;

if (this.isAnimated) {
setTimeout(() => this.hideModal(), TRANSITION_DURATION);
this.timerHideModal = setTimeout(() => this.hideModal(), TRANSITION_DURATION);
} else {
this.hideModal();
}
Expand Down Expand Up @@ -221,7 +231,8 @@ export class ModalDirective implements AfterViewInit, OnDestroy {

// todo: original show was calling a callback when done, but we can use promise
private showBackdrop(callback?: Function): void {
if (this._isShown && this.config.backdrop) {
if (this._isShown && this.config.backdrop && (!this.backdrop || !this.backdrop.instance.isShown)) {
this.removeBackdrop();
this.backdrop = this.componentsHelper
.appendNextToRoot(
ModalBackdropComponent,
Expand Down Expand Up @@ -255,7 +266,7 @@ export class ModalDirective implements AfterViewInit, OnDestroy {
};

if (this.backdrop.instance.isAnimated) {
setTimeout(callbackRemove, BACKDROP_TRANSITION_DURATION);
this.timerRmBackDrop = setTimeout(callbackRemove, BACKDROP_TRANSITION_DURATION);
} else {
callbackRemove();
}
Expand Down