Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show and hide triggers can now be set to the same event #208

Merged
merged 1 commit into from
May 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,24 @@
</span>
</div>

<div>
<span tooltips
tooltip-show-trigger="click"
tooltip-hide-trigger="click"
tooltip-template="Click again to close">
Tooltip with same trigger (click) for show and hide
</span>
</div>

<div>
<span tooltips
tooltip-show-trigger="mouseenter"
tooltip-hide-trigger="mouseenter"
tooltip-template="Mouseover again to close">
Tooltip with same trigger (mouseover) for show and hide
</span>
</div>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js"></script>
<script type="text/javascript" src="lib/angular-tooltips.js"></script>
<script type="text/javascript" src="demo/js/index.js"></script>
Expand Down
12 changes: 11 additions & 1 deletion lib/angular-tooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,11 @@
}
, onTooltipShow = function onTooltipShow(event) {

if (event && !tooltipElement.hasClass('active')) {

event.stopImmediatePropagation();
}

tipElement.addClass('_hidden');
if ($attrs.tooltipSmart) {

Expand Down Expand Up @@ -448,7 +453,12 @@
}
}
}
, onTooltipHide = function onTooltipHide() {
, onTooltipHide = function onTooltipHide(event) {

if (event && tooltipElement.hasClass('active')) {

event.stopImmediatePropagation();
}

if ($attrs.tooltipAppendToBody) {

Expand Down