-
Notifications
You must be signed in to change notification settings - Fork 6.7k
feat($tooltip): support for custom triggers #364
Conversation
The `$tooltip` service now has two ways to customize the default triggers. The `$tooltipProvider` takes a `trigger` option and the `*-trigger` attribute can be applied to a single element. The `$tooltipProvider`'s `trigger` option overwrites the default value but the attribute will overwrite both. A few logical default triggers are supported out of the box and have an associated map to determine which hide trigger to use. `mouseenter` -> `mouseleave`, `focus` -> `blur`, and `click` -> `click`. If any other trigger is provided, it will be used to both show and hide the tooltip. Custom hide triggers are not yet supported as they would require some code trickery due to the way `$observe` works. Closes #131
There's a lot of code changing here because some things had to be re-ordered to make sense under this PR. I also removed a bunch of duplicate tests that were a carryover from before we created the Also, as I mentioned when we created |
@joshdmiller this all looks great. There is just one part of the (existing) code that made me think. See my comment in the commit. But yeh, this is not directly related to the change discussed here. |
Landed as b1ba821. |
Hi guys, I'm trying to set the trigger option within the controller by using Since multiple triggers isn't possible yet (I've seen it's on your TODO list), what I want to do is detecting in the controller if it's a mobile browser being used and set the trigger to Any thoughts on that? |
@jc-tzn The I'm not sure what you mean by "multiple triggers", but each tooltip can also take a .controller( 'MyCtrl', function ($scope, FeatureDetection) {
if ( FeatureDetection.isMobile() ) {
$scope.tooltipTrigger = 'click';
} else {
$scope.tooltipTrigger = 'mouseenter';
}
}); And then: <a tooltip="This is the tooltip" tooltip-trigger="{{tooltipTrigger}}">Hover</a> |
aah yes indeed elegant solution thanks :) (I'm still not totally accustomed to angular philosophy) What I meant by "multiple triggers" was for example that the tooltip could be displayed on click as well as on mouseenter as the same time, but again your solution does the trick for me ! |
Is there a way to manually trigger the tooltip/popover ? I'm trying to find a way to trigger a tooltip/popover from another element. e.g.
|
@monkeymonk I want to do the same thing. No luck so far. 👍 |
The
$tooltip
service now has two ways to customize the default triggers.The
$tooltipProvider
takes atrigger
option and the*-trigger
attribute can be applied to a single element.
The
$tooltipProvider
'strigger
option overwrites the default valuebut the attribute will overwrite both.
A few logical default triggers are supported out of the box and have an
associated map to determine which hide trigger to use.
mouseenter
->mouseleave
,focus
->blur
, andclick
->click
. If any othertrigger is provided, it will be used to both show and hide the tooltip.
Custom hide triggers are not yet supported as they would require some
code trickery due to the way
$observe
works.Closes #131