@@ -131,7 +131,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
131
131
'animation="animation" ' +
132
132
'is-open="isOpen"' +
133
133
'origin-scope="origScope" ' +
134
- 'style="visibility: hidden; display: block; top: -9999px; left: -9999px; "' +
134
+ 'class="uib-position-measure "' +
135
135
'>' +
136
136
'</div>' ;
137
137
@@ -162,23 +162,29 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
162
162
163
163
if ( ! positionTimeout ) {
164
164
positionTimeout = $timeout ( function ( ) {
165
- // Reset the positioning.
166
- tooltip . css ( { top : 0 , left : 0 } ) ;
167
-
168
- // Now set the calculated positioning.
169
165
var ttPosition = $position . positionElements ( element , tooltip , ttScope . placement , appendToBody ) ;
170
- tooltip . css ( { top : ttPosition . top + 'px' , left : ttPosition . left + 'px' , visibility : 'visible' } ) ;
166
+ tooltip . css ( { top : ttPosition . top + 'px' , left : ttPosition . left + 'px' } ) ;
171
167
172
- if ( ttPosition . placement !== lastPlacement ) {
168
+ if ( ! tooltip . hasClass ( ttPosition . placement . split ( '-' ) [ 0 ] ) ) {
173
169
tooltip . removeClass ( lastPlacement . split ( '-' ) [ 0 ] ) ;
174
170
tooltip . addClass ( ttPosition . placement . split ( '-' ) [ 0 ] ) ;
171
+ }
175
172
173
+ if ( ! tooltip . hasClass ( options . placementClassPrefix + ttPosition . placement ) ) {
176
174
tooltip . removeClass ( options . placementClassPrefix + lastPlacement ) ;
177
175
tooltip . addClass ( options . placementClassPrefix + ttPosition . placement ) ;
176
+ }
178
177
178
+ // first time through tt element will have the
179
+ // uib-position-measure class or if the placement
180
+ // has changed we need to position the arrow.
181
+ if ( tooltip . hasClass ( 'uib-position-measure' ) ) {
182
+ $position . positionArrow ( tooltip , ttPosition . placement ) ;
183
+ tooltip . removeClass ( 'uib-position-measure' ) ;
184
+ } else if ( lastPlacement !== ttPosition . placement ) {
179
185
$position . positionArrow ( tooltip , ttPosition . placement ) ;
180
- lastPlacement = ttPosition . placement ;
181
186
}
187
+ lastPlacement = ttPosition . placement ;
182
188
183
189
positionTimeout = null ;
184
190
} , 0 , false ) ;
@@ -353,7 +359,8 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
353
359
354
360
ttScope . popupClass = attrs [ prefix + 'Class' ] ;
355
361
ttScope . placement = angular . isDefined ( attrs [ prefix + 'Placement' ] ) ? attrs [ prefix + 'Placement' ] : options . placement ;
356
- lastPlacement = '' ;
362
+ var placement = $position . parsePlacement ( ttScope . placement ) ;
363
+ lastPlacement = placement [ 1 ] ? placement [ 0 ] + '-' + placement [ 1 ] : placement [ 0 ] ;
357
364
358
365
var delay = parseInt ( attrs [ prefix + 'PopupDelay' ] , 10 ) ;
359
366
var closeDelay = parseInt ( attrs [ prefix + 'PopupCloseDelay' ] , 10 ) ;
@@ -443,6 +450,8 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s
443
450
observers . push (
444
451
attrs . $observe ( prefix + 'Placement' , function ( val ) {
445
452
ttScope . placement = val ? val : options . placement ;
453
+ var placement = $position . parsePlacement ( ttScope . placement ) ;
454
+ lastPlacement = placement [ 1 ] ? placement [ 0 ] + '-' + placement [ 1 ] : placement [ 0 ] ;
446
455
if ( ttScope . isOpen ) {
447
456
positionTooltip ( ) ;
448
457
}
@@ -631,8 +640,6 @@ function ($animate, $sce, $compile, $templateRequest) {
631
640
// // in TWBS, so we need the primary position.
632
641
var position = $uibPosition . parsePlacement ( scope . placement ) ;
633
642
element . addClass ( position [ 0 ] ) ;
634
- } else {
635
- element . addClass ( 'top' ) ;
636
643
}
637
644
638
645
if ( scope . popupClass ) {
0 commit comments