Skip to content

Commit 1d40207

Browse files
committed
Change implementation of disable interaction
Now uses a div that is child of the body element (not of the target element)
1 parent bf1e065 commit 1d40207

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

intro.js

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -341,17 +341,18 @@
341341
helperLayer.parentNode.removeChild(helperLayer);
342342
}
343343

344+
//remove disableInteractionLayer
345+
var disableInteractionLayer = targetElement.querySelector('.introjs-disableInteraction');
346+
if(disableInteractionLayer){
347+
disableInteractionLayer.parentNode.removeChild(disableInteractionLayer);
348+
}
349+
344350
//remove intro floating element
345351
var floatingElement = document.querySelector('.introjsFloatingElement');
346352
if (floatingElement) {
347353
floatingElement.parentNode.removeChild(floatingElement);
348354
}
349355

350-
//remove element overlay
351-
if (this._options.disableInteraction === true) {
352-
document.querySelector('.introjs-elementOverlay').remove();
353-
}
354-
355356
//remove `introjs-showElement` class from the element
356357
var showElement = document.querySelector('.introjs-showElement');
357358
if (showElement) {
@@ -510,6 +511,16 @@
510511
}
511512
}
512513

514+
function _disableInteraction(){
515+
disableInteractionLayer = document.querySelector('.introjs-disableInteraction');
516+
if (disableInteractionLayer === null){
517+
disableInteractionLayer = document.createElement('div');
518+
disableInteractionLayer.className = 'introjs-disableInteraction';
519+
this._targetElement.appendChild(disableInteractionLayer);
520+
}
521+
_setHelperLayerPosition.call(this, disableInteractionLayer);
522+
523+
}
513524
/**
514525
* Show an element on the page
515526
*
@@ -562,11 +573,6 @@
562573
var oldShowElement = document.querySelector('.introjs-showElement');
563574
oldShowElement.className = oldShowElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, '');
564575

565-
//remove element overlay
566-
if (this._options.disableInteraction === true) {
567-
document.querySelector('.introjs-elementOverlay').remove();
568-
}
569-
570576
//we should wait until the CSS3 transition is competed (it's 0.3 sec) to prevent incorrect `height` and `width` calculation
571577
if (self._lastShowElementTimer) {
572578
clearTimeout(self._lastShowElementTimer);
@@ -617,6 +623,7 @@
617623
bulletsLayer.style.display = 'none';
618624
}
619625

626+
620627
var ulContainer = document.createElement('ul');
621628

622629
for (var i = 0, stepsLength = this._introItems.length; i < stepsLength; i++) {
@@ -655,6 +662,7 @@
655662
helperNumberLayer.innerHTML = targetElement.step;
656663
helperLayer.appendChild(helperNumberLayer);
657664
}
665+
658666
tooltipLayer.appendChild(arrowLayer);
659667
helperLayer.appendChild(tooltipLayer);
660668

@@ -714,6 +722,10 @@
714722
_placeTooltip.call(self, targetElement.element, tooltipLayer, arrowLayer, helperNumberLayer);
715723
}
716724

725+
//disable interaction
726+
if (this._options.disableInteraction === true){
727+
_disableInteraction.call(self);
728+
}
717729
if (this._currentStep == 0 && this._introItems.length > 1) {
718730
prevTooltipButton.className = 'introjs-button introjs-prevbutton introjs-disabled';
719731
nextTooltipButton.className = 'introjs-button introjs-nextbutton';
@@ -731,13 +743,6 @@
731743
//Set focus on "next" button, so that hitting Enter always moves you onto the next step
732744
nextTooltipButton.focus();
733745

734-
//add inner div to prevent posibility interact with element (transparent overlay)
735-
if (this._options.disableInteraction === true) {
736-
var elementOverlay = document.createElement('div');
737-
elementOverlay.className = 'introjs-elementOverlay';
738-
targetElement.element.appendChild(elementOverlay);
739-
}
740-
741746
//add target element position style
742747
targetElement.element.className += ' introjs-showElement';
743748

introjs.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@ tr.introjs-showElement > th {
3030
z-index: 9999999 !important;
3131
}
3232

33-
.introjs-elementOverlay {
33+
.introjs-disableInteraction {
3434
z-index: 99999999 !important;
3535
position: absolute;
36-
width: 100%;
37-
height: 100%;
38-
top: 0;
39-
left: 0;
4036
}
4137

4238
.introjs-relativePosition,

0 commit comments

Comments
 (0)