|
419 | 419 | var tooltipCssClass = '',
|
420 | 420 | currentStepObj,
|
421 | 421 | tooltipOffset,
|
422 |
| - targetElementOffset, |
| 422 | + targetOffset, |
| 423 | + windowSize, |
423 | 424 | currentTooltipPosition;
|
424 | 425 |
|
425 | 426 | //reset the old style
|
|
456 | 457 | currentTooltipPosition = _determineAutoPosition.call(this, targetElement, tooltipLayer, currentTooltipPosition)
|
457 | 458 | }
|
458 | 459 | }
|
459 |
| - var targetOffset = _getOffset(targetElement); |
460 |
| - var tooltipHeight = _getOffset(tooltipLayer).height; |
461 |
| - var windowSize = _getWinSize(); |
| 460 | + targetOffset = _getOffset(targetElement); |
| 461 | + tooltipOffset = _getOffset(tooltipLayer); |
| 462 | + windowSize = _getWinSize(); |
462 | 463 | switch (currentTooltipPosition) {
|
463 | 464 | case 'top':
|
464 | 465 | tooltipLayer.style.left = '15px';
|
465 |
| - tooltipLayer.style.top = '-' + (tooltipHeight + 10) + 'px'; |
| 466 | + tooltipLayer.style.top = '-' + (tooltipOffset.height + 10) + 'px'; |
466 | 467 | arrowLayer.className = 'introjs-arrow bottom';
|
467 | 468 | break;
|
468 | 469 | case 'right':
|
469 |
| - tooltipLayer.style.left = (_getOffset(targetElement).width + 20) + 'px'; |
470 |
| - if (targetOffset.top + tooltipHeight > windowSize.height) { |
| 470 | + tooltipLayer.style.left = (targetOffset.width + 20) + 'px'; |
| 471 | + if (targetOffset.top + tooltipOffset.height > windowSize.height) { |
471 | 472 | // In this case, right would have fallen below the bottom of the screen.
|
472 | 473 | // Modify so that the bottom of the tooltip connects with the target
|
473 | 474 | arrowLayer.className = "introjs-arrow left-bottom";
|
474 |
| - tooltipLayer.style.top = "-" + (tooltipHeight - targetOffset.height - 20) + "px" |
| 475 | + tooltipLayer.style.top = "-" + (tooltipOffset.height - targetOffset.height - 20) + "px" |
475 | 476 | }
|
476 | 477 | arrowLayer.className = 'introjs-arrow left';
|
477 | 478 | break;
|
|
480 | 481 | tooltipLayer.style.top = '15px';
|
481 | 482 | }
|
482 | 483 |
|
483 |
| - if (targetOffset.top + tooltipHeight > windowSize.height) { |
| 484 | + if (targetOffset.top + tooltipOffset.height > windowSize.height) { |
484 | 485 | // In this case, left would have fallen below the bottom of the screen.
|
485 | 486 | // Modify so that the bottom of the tooltip connects with the target
|
486 |
| - tooltipLayer.style.top = "-" + (tooltipHeight - targetOffset.height - 20) + "px"; |
| 487 | + tooltipLayer.style.top = "-" + (tooltipOffset.height - targetOffset.height - 20) + "px"; |
487 | 488 | arrowLayer.className = 'introjs-arrow right-bottom';
|
488 | 489 | } else {
|
489 | 490 | arrowLayer.className = 'introjs-arrow right';
|
|
496 | 497 | arrowLayer.style.display = 'none';
|
497 | 498 |
|
498 | 499 | //we have to adjust the top and left of layer manually for intro items without element
|
499 |
| - tooltipOffset = _getOffset(tooltipLayer); |
500 |
| - |
501 | 500 | tooltipLayer.style.left = '50%';
|
502 | 501 | tooltipLayer.style.top = '50%';
|
503 | 502 | tooltipLayer.style.marginLeft = '-' + (tooltipOffset.width / 2) + 'px';
|
|
512 | 511 | case 'bottom-right-aligned':
|
513 | 512 | arrowLayer.className = 'introjs-arrow top-right';
|
514 | 513 | tooltipLayer.style.right = '0px';
|
515 |
| - tooltipLayer.style.bottom = '-' + (_getOffset(tooltipLayer).height + 10) + 'px'; |
| 514 | + tooltipLayer.style.bottom = '-' + (tooltipOffset.height + 10) + 'px'; |
516 | 515 | break;
|
517 | 516 | case 'bottom-middle-aligned':
|
518 |
| - targetElementOffset = _getOffset(targetElement); |
519 |
| - tooltipOffset = _getOffset(tooltipLayer); |
520 |
| - |
521 | 517 | arrowLayer.className = 'introjs-arrow top-middle';
|
522 |
| - var tooltipLayerStyleLeft = targetElementOffset.width / 2 - tooltipOffset.width / 2; |
| 518 | + var tooltipLayerStyleLeft = targetOffset.width / 2 - tooltipOffset.width / 2; |
523 | 519 | // off the right side of the window
|
524 |
| - if (targetElementOffset.left + tooltipLayerStyleLeft + tooltipOffset.width > windowSize.width) |
525 |
| - tooltipLayer.style.left = (windowSize.width - tooltipOffset.width - targetElementOffset.left) + 'px'; |
| 520 | + if (targetOffset.left + tooltipLayerStyleLeft + tooltipOffset.width > windowSize.width) |
| 521 | + tooltipLayer.style.left = (windowSize.width - tooltipOffset.width - targetOffset.left) + 'px'; |
526 | 522 | else
|
527 | 523 | tooltipLayer.style.left = tooltipLayerStyleLeft + 'px';
|
528 |
| - tooltipLayer.style.top = (targetElementOffset.height + 20) + 'px'; |
| 524 | + tooltipLayer.style.top = (targetOffset.height + 20) + 'px'; |
529 | 525 | break;
|
530 | 526 | case 'bottom-left-aligned':
|
531 | 527 | // Bottom-left-aligned is the same as the default bottom
|
532 | 528 | case 'bottom':
|
533 | 529 | // Bottom going to follow the default behavior
|
534 | 530 | default:
|
535 |
| - tooltipLayer.style.bottom = '-' + (_getOffset(tooltipLayer).height + 10) + 'px'; |
536 |
| - tooltipLayer.style.left = (_getOffset(targetElement).width / 2 - _getOffset(tooltipLayer).width / 2) + 'px'; |
| 531 | + tooltipLayer.style.bottom = '-' + (tooltipOffset.height + 10) + 'px'; |
| 532 | + tooltipLayer.style.left = (targetOffset.width / 2 - tooltipOffset.width / 2) + 'px'; |
537 | 533 |
|
538 | 534 | arrowLayer.className = 'introjs-arrow top';
|
539 | 535 | break;
|
|
0 commit comments