Skip to content

Commit aba87c2

Browse files
author
Alexandre-io
committed
feat(showArrow): show/hide arrow from tooltip
1 parent dc0dbcc commit aba87c2

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ introductionjs().onafterchange(function(targetElement) {
290290
- `showSkipButton`: Show skip button or not, `true` or `false`
291291
- `showBullets`: Show introduction bullets or not, `true` or `false`
292292
- `showProgress`: Show introduction progress or not, `true` or `false`
293+
- `showArrow`: Show arrow to dialog or not, `true` or `false`
293294
- `scrollToElement`: Auto scroll to highlighted element if it's outside of viewport, `true` or `false`
294295
- `overlayOpacity`: Adjust the overlay opacity, `Number`
295296
- `disableInteraction`: Disable an interaction inside element or not, `true` or `false`

src/introduction.js

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
showBullets: true,
6161
/* Show tour progress? */
6262
showProgress: false,
63+
/* Show arrow to dialog */
64+
showArrow: false,
6365
/* Scroll to highlighted element? */
6466
scrollToElement: true,
6567
/* Set the overlay opacity */
@@ -509,7 +511,9 @@
509511
var tooltipLayerStyleLeft = 0;
510512
switch (currentTooltipPosition) {
511513
case 'top':
512-
arrowLayer.className = 'introjs-arrow bottom';
514+
if (this._options.showArrow) {
515+
arrowLayer.className = 'introjs-arrow bottom';
516+
}
513517

514518
tooltipLayerStyleLeft = 15;
515519
_checkRight(targetOffset, tooltipLayerStyleLeft, tooltipOffset, windowSize, tooltipLayer);
@@ -520,10 +524,12 @@
520524
if (targetOffset.top + tooltipOffset.height > windowSize.height) {
521525
// In this case, right would have fallen below the bottom of the screen.
522526
// Modify so that the bottom of the tooltip connects with the target
523-
arrowLayer.className = "introjs-arrow left-bottom";
527+
if (this._options.showArrow) {
528+
arrowLayer.className = "introjs-arrow left-bottom";
529+
}
524530
tooltipLayer.style.top = "-" + (tooltipOffset.height - targetOffset.height - 20) + "px";
525531
}
526-
else {
532+
else if (this._options.showArrow) {
527533
arrowLayer.className = 'introjs-arrow left';
528534
}
529535
break;
@@ -536,10 +542,13 @@
536542
// In this case, left would have fallen below the bottom of the screen.
537543
// Modify so that the bottom of the tooltip connects with the target
538544
tooltipLayer.style.top = "-" + (tooltipOffset.height - targetOffset.height - 20) + "px";
539-
arrowLayer.className = 'introjs-arrow right-bottom';
545+
if (this._options.showArrow) {
546+
arrowLayer.className = 'introjs-arrow right-bottom';
547+
}
540548
}
541-
else {
549+
else if (this._options.showArrow) {
542550
arrowLayer.className = 'introjs-arrow right';
551+
543552
}
544553
tooltipLayer.style.right = (targetOffset.width + 20) + 'px';
545554

@@ -560,15 +569,19 @@
560569

561570
break;
562571
case 'bottom-right-aligned':
563-
arrowLayer.className = 'introjs-arrow top-right';
572+
if (this._options.showArrow) {
573+
arrowLayer.className = 'introjs-arrow top-right';
574+
}
564575

565576
var tooltipLayerStyleRight = 0;
566577
_checkLeft(targetOffset, tooltipLayerStyleRight, tooltipOffset, tooltipLayer);
567578
tooltipLayer.style.top = (targetOffset.height + 20) + 'px';
568579
break;
569580

570581
case 'bottom-middle-aligned':
571-
arrowLayer.className = 'introjs-arrow top-middle';
582+
if (this._options.showArrow) {
583+
arrowLayer.className = 'introjs-arrow top-middle';
584+
}
572585

573586
var tooltipLayerStyleLeftRight = targetOffset.width / 2 - tooltipOffset.width / 2;
574587
if (_checkLeft(targetOffset, tooltipLayerStyleLeftRight, tooltipOffset, tooltipLayer)) {
@@ -578,7 +591,9 @@
578591
tooltipLayer.style.top = (targetOffset.height + 20) + 'px';
579592
break;
580593
default:
581-
arrowLayer.className = 'introjs-arrow top';
594+
if (this._options.showArrow) {
595+
arrowLayer.className = 'introjs-arrow top';
596+
}
582597

583598
_checkRight(targetOffset, tooltipLayerStyleLeft, tooltipOffset, windowSize, tooltipLayer);
584599
tooltipLayer.style.top = (targetOffset.height + 20) + 'px';

0 commit comments

Comments
 (0)