Skip to content
This repository has been archived by the owner on Nov 24, 2017. It is now read-only.

delay emitting onOpen event #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ build/
factories/
node_modules
npm-debug.log
.vscode
debug.log
16 changes: 10 additions & 6 deletions src/Modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,28 @@ export class Modal {
// -------------------------------------------------------------------------

open(...args: any[]) {
if (this.isOpened)
return;
if (this.isOpened) return;

this.isOpened = true;
this.onOpen.emit(args);
document.body.appendChild(this.backdropElement);
window.setTimeout(() => this.modalRoot.nativeElement.focus(), 0);

window.setTimeout(() => {
this.modalRoot.nativeElement.focus();
this.onOpen.emit(args);
}, 0);

document.body.className += " modal-open";
}

close(...args: any[]) {
if (!this.isOpened)
return;

this.isOpened = false;
this.onClose.emit(args);
document.body.removeChild(this.backdropElement);
document.body.className = document.body.className.replace(/modal-open\b/, "");

this.isOpened = false;
this.onClose.emit(args);
}

// -------------------------------------------------------------------------
Expand Down