Skip to content

Commit

Permalink
refactor: implement overlay stack per plugin for vex & bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
Shlomi Assaf (shlassaf) committed Aug 23, 2016
1 parent 18acd51 commit ab4d51a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/components/angular2-modal/plugins/bootstrap/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export class Modal extends Modal_ {
}

// on removal, remove if last.
dialogRef.onDestroy
.subscribe(() => this.overlay.stackLength === 0 && document.body.classList.remove('modal-open'));
// dialogRef.onDestroy
// .subscribe(() => this.overlay.groupStackLength(dialogRef) === 0 && document.body.classList.remove('modal-open'));

backdrop.addClass('modal-backdrop fade');
backdrop.addClass('in', true);
Expand All @@ -90,7 +90,10 @@ export class Modal extends Modal_ {
// running inside zone didn't help.
overlay.tick();

backdrop.animationEnd$.first().subscribe(type => completer.resolve());
backdrop.animationEnd$.first().subscribe(type => {
this.overlay.groupStackLength(dialogRef) === 1 && document.body.classList.remove('modal-open');
completer.resolve()
});

return completer.promise;
});
Expand Down
10 changes: 6 additions & 4 deletions src/components/angular2-modal/plugins/vex/modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ export class Modal extends Modal_ {
if (!document.body.classList.contains('vex-open')) {
document.body.classList.add('vex-open');
}
// on removal, remove if last.
dialogRef.onDestroy
.subscribe(() => this.overlay.stackLength === 0 && document.body.classList.remove('vex-open'));

overlay.addClass(`vex vex-theme-${dialogRef.context.className}`);
backdrop.addClass('vex-overlay');
Expand Down Expand Up @@ -87,7 +84,12 @@ export class Modal extends Modal_ {
overlay.tick();

const completer = new PromiseCompleter<void>();
container.animationEnd$.first().subscribe(type => completer.resolve());
container.animationEnd$.first().subscribe(type => {
// on removal, remove if last.

this.overlay.groupStackLength(dialogRef) === 1 && document.body.classList.remove('vex-open');
completer.resolve()
});
return completer.promise;
});

Expand Down

0 comments on commit ab4d51a

Please sign in to comment.