|
214 | 214 | if (showElement) {
|
215 | 215 | showElement.className = showElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, ''); // This is a manual trim.
|
216 | 216 | }
|
| 217 | + |
| 218 | + //remove `introjs-fixParent` class from the elements |
| 219 | + var fixParents = document.querySelectorAll('.introjs-fixParent'); |
| 220 | + if (fixParents && fixParents.length > 0) { |
| 221 | + for (var i = fixParents.length - 1; i >= 0; i--) { |
| 222 | + fixParents[i].className = fixParents[i].className.replace(/introjs-fixParent/g, '').replace(/^\s+|\s+$/g, ''); |
| 223 | + }; |
| 224 | + } |
217 | 225 | //clean listeners
|
218 | 226 | if (window.removeEventListener) {
|
219 | 227 | window.removeEventListener('keydown', this._onKeyDown, true);
|
|
302 | 310 | * @param {Object} targetElement
|
303 | 311 | */
|
304 | 312 | function _showElement(targetElement) {
|
305 |
| - |
| 313 | + |
306 | 314 | if (typeof (this._introChangeCallback) !== 'undefined') {
|
307 | 315 | this._introChangeCallback.call(this, targetElement.element);
|
308 | 316 | }
|
|
326 | 334 | //set new position to helper layer
|
327 | 335 | _setHelperLayerPosition.call(self, oldHelperLayer);
|
328 | 336 |
|
| 337 | + //remove `introjs-fixParent` class from the elements |
| 338 | + var fixParents = document.querySelectorAll('.introjs-fixParent'); |
| 339 | + if (fixParents && fixParents.length > 0) { |
| 340 | + for (var i = fixParents.length - 1; i >= 0; i--) { |
| 341 | + fixParents[i].className = fixParents[i].className.replace(/introjs-fixParent/g, '').replace(/^\s+|\s+$/g, ''); |
| 342 | + }; |
| 343 | + } |
| 344 | + |
329 | 345 | //remove old classes
|
330 | 346 | var oldShowElement = document.querySelector('.introjs-showElement');
|
331 | 347 | oldShowElement.className = oldShowElement.className.replace(/introjs-[a-zA-Z]+/g, '').replace(/^\s+|\s+$/g, '');
|
|
433 | 449 | //add target element position style
|
434 | 450 | targetElement.element.className += ' introjs-showElement';
|
435 | 451 |
|
436 |
| - //Thanks to JavaScript Kit: http://www.javascriptkit.com/dhtmltutors/dhtmlcascade4.shtml |
437 |
| - var currentElementPosition = ''; |
438 |
| - if (targetElement.element.currentStyle) { //IE |
439 |
| - currentElementPosition = targetElement.element.currentStyle['position']; |
440 |
| - } else if (document.defaultView && document.defaultView.getComputedStyle) { //Firefox |
441 |
| - currentElementPosition = document.defaultView.getComputedStyle(targetElement.element, null).getPropertyValue('position'); |
442 |
| - } |
443 |
| - |
444 |
| - //I don't know is this necessary or not, but I clear the position for better comparing |
445 |
| - currentElementPosition = currentElementPosition.toLowerCase(); |
| 452 | + var currentElementPosition = _getPropValue(targetElement.element, 'position'); |
446 | 453 | if (currentElementPosition !== 'absolute' &&
|
447 | 454 | currentElementPosition !== 'relative') {
|
448 | 455 | //change to new intro item
|
449 | 456 | targetElement.element.className += ' introjs-relativePosition';
|
450 | 457 | }
|
451 | 458 |
|
| 459 | + var parentElm = targetElement.element.parentNode; |
| 460 | + while(parentElm != null) { |
| 461 | + if(parentElm.tagName.toLowerCase() === 'body') break; |
| 462 | + |
| 463 | + var zIndex = _getPropValue(parentElm, 'z-index'); |
| 464 | + if(/[0-9]+/.test(zIndex)) { |
| 465 | + parentElm.className += ' introjs-fixParent'; |
| 466 | + } |
| 467 | + parentElm = parentElm.parentNode; |
| 468 | + } |
| 469 | + |
452 | 470 | if (!_elementInViewport(targetElement.element)) {
|
453 | 471 | var rect = targetElement.element.getBoundingClientRect(),
|
454 | 472 | top = rect.bottom - (rect.bottom - rect.top),
|
|
465 | 483 | }
|
466 | 484 | }
|
467 | 485 |
|
| 486 | + /** |
| 487 | + * Get an element CSS property on the page |
| 488 | + * Thanks to JavaScript Kit: http://www.javascriptkit.com/dhtmltutors/dhtmlcascade4.shtml |
| 489 | + * |
| 490 | + * @api private |
| 491 | + * @method _getPropValue |
| 492 | + * @param {Object} element |
| 493 | + * @param {String} propName |
| 494 | + * @returns Element's property value |
| 495 | + */ |
| 496 | + function _getPropValue (element, propName) { |
| 497 | + var propValue = ''; |
| 498 | + if (element.currentStyle) { //IE |
| 499 | + propValue = element.currentStyle[propName]; |
| 500 | + } else if (document.defaultView && document.defaultView.getComputedStyle) { //Others |
| 501 | + propValue = document.defaultView.getComputedStyle(element, null).getPropertyValue(propName); |
| 502 | + } |
| 503 | + |
| 504 | + //Prevent exception in IE |
| 505 | + if(propValue.toLowerCase) { |
| 506 | + return propValue.toLowerCase(); |
| 507 | + } else { |
| 508 | + return propValue; |
| 509 | + } |
| 510 | + } |
| 511 | + |
468 | 512 | /**
|
469 | 513 | * Provides a cross-browser way to get the screen dimensions
|
470 | 514 | * via: http://stackoverflow.com/questions/5864467/internet-explorer-innerheight
|
|
0 commit comments