@@ -58,18 +58,19 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
58
58
59
59
var parent = $mdUtil . getParentWithPointerEvents ( element ) ,
60
60
content = angular . element ( element [ 0 ] . getElementsByClassName ( 'md-content' ) [ 0 ] ) ,
61
- current = $mdUtil . getNearestContentElement ( element ) ,
62
- tooltipParent = angular . element ( current || document . body ) ,
61
+ tooltipParent = angular . element ( document . body ) ,
63
62
debouncedOnResize = $$rAF . throttle ( function ( ) { updatePosition ( ) ; } ) ;
64
63
64
+ if ( $animate . pin ) $animate . pin ( element , parent ) ;
65
+
65
66
// Initialize element
66
67
67
68
setDefaults ( ) ;
68
69
manipulateElement ( ) ;
69
70
bindEvents ( ) ;
70
71
71
- // Default origin transform point is 'left top'
72
- // positionTooltip() is always relative to top left
72
+ // Default origin transform point is 'center top'
73
+ // positionTooltip() is always relative to center top
73
74
updateContentOrigin ( ) ;
74
75
75
76
configureWatchers ( ) ;
@@ -81,7 +82,7 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
81
82
}
82
83
83
84
function updateContentOrigin ( ) {
84
- var origin = 'left top' ;
85
+ var origin = 'center top' ;
85
86
switch ( scope . direction ) {
86
87
case 'left' : origin = 'right center' ; break ;
87
88
case 'right' : origin = 'left center' ; break ;
@@ -137,19 +138,25 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
137
138
} ) ;
138
139
139
140
attributeObserver . observe ( parent [ 0 ] , { attributes : true } ) ;
140
- } ;
141
+ }
141
142
142
143
// Store whether the element was focused when the window loses focus.
143
144
var windowBlurHandler = function ( ) {
144
145
elementFocusedOnWindowBlur = document . activeElement === parent [ 0 ] ;
145
146
} ;
146
147
var elementFocusedOnWindowBlur = false ;
147
148
149
+ function windowScrollHandler ( ) {
150
+ setVisible ( false ) ;
151
+ }
152
+
148
153
ngWindow . on ( 'blur' , windowBlurHandler ) ;
149
154
ngWindow . on ( 'resize' , debouncedOnResize ) ;
155
+ document . addEventListener ( 'scroll' , windowScrollHandler , true ) ;
150
156
scope . $on ( '$destroy' , function ( ) {
151
157
ngWindow . off ( 'blur' , windowBlurHandler ) ;
152
158
ngWindow . off ( 'resize' , debouncedOnResize ) ;
159
+ document . removeEventListener ( 'scroll' , windowScrollHandler , true ) ;
153
160
attributeObserver && attributeObserver . disconnect ( ) ;
154
161
} ) ;
155
162
0 commit comments