Skip to content

Commit

Permalink
Update overlay-mixin.html
Browse files Browse the repository at this point in the history
  • Loading branch information
pdgago authored Dec 19, 2017
1 parent 430f361 commit fced287
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions overlay-mixin.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,24 @@

constructor() {
super();
this.__movingToContainer = false;
this.__onOverlayKeydown = this.__onOverlayKeydown.bind(this);
this._handleCancelOnOutsideClick = this._handleCancelOnOutsideClick.bind(this);
}

connectedCallback() {
this._ensureAttribute('tabindex', -1);
if (!this.opened) {
this.style.display = 'none';
}
super.connectedCallback();
}

disconnectedCallback() {
super.disconnectedCallback();
if (this.__movingToContainer) {
return;
}
if (this.opened) {
this.opened = false;
this.__dispatchOverlayEvent('overlay-closed', {node: this.parentContainer});
Expand Down Expand Up @@ -125,8 +132,19 @@
});
if ((!this.isConnected) ||
(this.parentElement !== this.parentContainer)) {
if (this.isConnected) {
this.__movingToContainer = true;
}
// Attach the overlay to the parentContainer
this.__attachToParentContainer();
this.__movingToContainer = false;
}
}

__attachToParentContainer() {
try {
this.parentContainer.appendChild(this);
} catch(e) {
}
}

Expand Down

0 comments on commit fced287

Please sign in to comment.