Skip to content

Commit ed34835

Browse files
committed
Merge pull request usablica#304 from Codility/disable-interaction
Disable interaction
2 parents 9261f10 + 1d40207 commit ed34835

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ introJs().onafterchange(function(targetElement) {
349349
- `showBullets`: Show introduction bullets or not, `true` or `false`
350350
- `scrollToElement`: Auto scroll to highlighted element if it's outside of viewport, `true` or `false`
351351
- `overlayOpacity`: Adjust the overlay opacity, `Number`
352+
- `disableInteraction`: Disable an interaction inside element or not, `true` or `false`
352353
353354
See [setOption](https://github.com/usablica/intro.js/#introjssetoptionoption-value) to see an example.
354355

intro.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@
5757
/* Scroll to highlighted element? */
5858
scrollToElement: true,
5959
/* Set the overlay opacity */
60-
overlayOpacity: 0.8
60+
overlayOpacity: 0.8,
61+
/* Disable an interaction with element? */
62+
disableInteraction: false
6163
};
6264
}
6365

@@ -339,6 +341,12 @@
339341
helperLayer.parentNode.removeChild(helperLayer);
340342
}
341343

344+
//remove disableInteractionLayer
345+
var disableInteractionLayer = targetElement.querySelector('.introjs-disableInteraction');
346+
if(disableInteractionLayer){
347+
disableInteractionLayer.parentNode.removeChild(disableInteractionLayer);
348+
}
349+
342350
//remove intro floating element
343351
var floatingElement = document.querySelector('.introjsFloatingElement');
344352
if (floatingElement) {
@@ -503,6 +511,16 @@
503511
}
504512
}
505513

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+
}
506524
/**
507525
* Show an element on the page
508526
*
@@ -554,6 +572,7 @@
554572
//remove old classes
555573
var oldShowElement = document.querySelector('.introjs-showElement');
556574
oldShowElement.className = oldShowElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, '');
575+
557576
//we should wait until the CSS3 transition is competed (it's 0.3 sec) to prevent incorrect `height` and `width` calculation
558577
if (self._lastShowElementTimer) {
559578
clearTimeout(self._lastShowElementTimer);
@@ -604,6 +623,7 @@
604623
bulletsLayer.style.display = 'none';
605624
}
606625

626+
607627
var ulContainer = document.createElement('ul');
608628

609629
for (var i = 0, stepsLength = this._introItems.length; i < stepsLength; i++) {
@@ -642,6 +662,7 @@
642662
helperNumberLayer.innerHTML = targetElement.step;
643663
helperLayer.appendChild(helperNumberLayer);
644664
}
665+
645666
tooltipLayer.appendChild(arrowLayer);
646667
helperLayer.appendChild(tooltipLayer);
647668

@@ -701,6 +722,10 @@
701722
_placeTooltip.call(self, targetElement.element, tooltipLayer, arrowLayer, helperNumberLayer);
702723
}
703724

725+
//disable interaction
726+
if (this._options.disableInteraction === true){
727+
_disableInteraction.call(self);
728+
}
704729
if (this._currentStep == 0 && this._introItems.length > 1) {
705730
prevTooltipButton.className = 'introjs-button introjs-prevbutton introjs-disabled';
706731
nextTooltipButton.className = 'introjs-button introjs-nextbutton';

introjs.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ tr.introjs-showElement > th {
3636
z-index: 9999999 !important;
3737
}
3838

39+
.introjs-disableInteraction {
40+
z-index: 99999999 !important;
41+
position: absolute;
42+
}
43+
3944
.introjs-relativePosition,
4045
tr.introjs-showElement > td,
4146
tr.introjs-showElement > th {

0 commit comments

Comments
 (0)