Skip to content

Commit 6ac9cf6

Browse files
committed
Show and hide triggers can now be set to the same event.
1 parent 2e57ad7 commit 6ac9cf6

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

index.html

+18
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,24 @@
423423
</span>
424424
</div>
425425

426+
<div>
427+
<span tooltips
428+
tooltip-show-trigger="click"
429+
tooltip-hide-trigger="click"
430+
tooltip-template="Click again to close">
431+
Tooltip with same trigger (click) for show and hide
432+
</span>
433+
</div>
434+
435+
<div>
436+
<span tooltips
437+
tooltip-show-trigger="mouseenter"
438+
tooltip-hide-trigger="mouseenter"
439+
tooltip-template="Mouseover again to close">
440+
Tooltip with same trigger (mouseover) for show and hide
441+
</span>
442+
</div>
443+
426444
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js"></script>
427445
<script type="text/javascript" src="lib/angular-tooltips.js"></script>
428446
<script type="text/javascript" src="demo/js/index.js"></script>

lib/angular-tooltips.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@
328328
}
329329
, onTooltipShow = function onTooltipShow(event) {
330330

331+
if (event && !tooltipElement.hasClass('active')) {
332+
333+
event.stopImmediatePropagation();
334+
}
335+
331336
tipElement.addClass('_hidden');
332337
if ($attrs.tooltipSmart) {
333338

@@ -448,7 +453,12 @@
448453
}
449454
}
450455
}
451-
, onTooltipHide = function onTooltipHide() {
456+
, onTooltipHide = function onTooltipHide(event) {
457+
458+
if (event && tooltipElement.hasClass('active')) {
459+
460+
event.stopImmediatePropagation();
461+
}
452462

453463
if ($attrs.tooltipAppendToBody) {
454464

0 commit comments

Comments
 (0)