Skip to content

Commit

Permalink
Add createModalOverlay function (#358)
Browse files Browse the repository at this point in the history
Fixes #347
  • Loading branch information
RobbieTheWagner authored Apr 22, 2019
1 parent 1635e64 commit 5ec4c04
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
28 changes: 17 additions & 11 deletions src/js/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,7 @@ import defer from 'lodash-es/defer';

export class Modal {
constructor(options) {
if (!this._modalOverlayElem) {
this._modalOverlayElem = createModalOverlay();
this._modalOverlayOpening = getModalMaskOpening(this._modalOverlayElem);

// don't show yet -- each step will control that
this.hide();

document.body.appendChild(this._modalOverlayElem);
}

this.createModalOverlay();
this.options = options;

return this;
Expand All @@ -42,6 +33,21 @@ export class Modal {
});
}

/**
* Create the modal overlay, if it does not already exist
*/
createModalOverlay() {
if (!this._modalOverlayElem) {
this._modalOverlayElem = createModalOverlay();
this._modalOverlayOpening = getModalMaskOpening(this._modalOverlayElem);

// don't show yet -- each step will control that
this.hide();

document.body.appendChild(this._modalOverlayElem);
}
}

/**
* Hide the modal overlay
*/
Expand Down Expand Up @@ -102,4 +108,4 @@ export class Modal {
closeModalOpening(this._modalOverlayOpening);
}
}
}
}
4 changes: 3 additions & 1 deletion src/js/tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export class Tour extends Evented {
})(event);
});

this.modal = new Modal(options);

this._setTooltipDefaults();
this._setTourID();

Expand Down Expand Up @@ -309,7 +311,7 @@ export class Tour extends Evented {
* @private
*/
_setupActiveTour() {
this.modal = new Modal(this.options);
this.modal.createModalOverlay();
this._addBodyAttrs();
this.trigger('active', { tour: this });

Expand Down

0 comments on commit 5ec4c04

Please sign in to comment.