-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Tooltip positioning & placement improvements #3980
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,6 +136,10 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap | |
tooltip.css( ttPosition ); | ||
}; | ||
|
||
var positionTooltipAsync = function () { | ||
$timeout(positionTooltip, 0, false); | ||
}; | ||
|
||
// Set up the correct scope to allow transclusion later | ||
ttScope.origScope = scope; | ||
|
||
|
@@ -246,12 +250,9 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap | |
} | ||
}); | ||
|
||
tooltipLinkedScope.$watch(function () { | ||
$timeout(positionTooltip, 0, false); | ||
}); | ||
|
||
if (options.useContentExp) { | ||
tooltipLinkedScope.$watch('contentExp()', function (val) { | ||
positionTooltipAsync(); | ||
if (!val && ttScope.isOpen ) { | ||
hide(); | ||
} | ||
|
@@ -287,6 +288,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap | |
if (!options.useContentExp) { | ||
attrs.$observe( type, function ( val ) { | ||
ttScope.content = val; | ||
positionTooltipAsync(); | ||
|
||
if (!val && ttScope.isOpen ) { | ||
hide(); | ||
|
@@ -302,6 +304,16 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap | |
|
||
attrs.$observe( prefix+'Title', function ( val ) { | ||
ttScope.title = val; | ||
positionTooltipAsync(); | ||
}); | ||
|
||
attrs.$observe( prefix + 'Placement', function () { | ||
if (ttScope.isOpen) { | ||
$timeout(function () { | ||
prepPlacement(); | ||
show()(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't this mean that if the placement is changed while the tooltip is hidden, it'll show? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, it only runs if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, I missed that check, but there's also when the value is a blank string, see above at line #288: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a slightly different case that warrants a different conditional. On 288, there's new content to deal with and if the content is blank, it should hide the tooltip. Here there's no new content, just a new placement. |
||
}, 0, false); | ||
} | ||
}); | ||
|
||
function prepPopupClass() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might also need to schedule a reposition over here since if
contentExp()
changes, the content changes as well.