@@ -58,18 +58,19 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
5858
5959 var parent = $mdUtil . getParentWithPointerEvents ( element ) ,
6060 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 ) ,
6362 debouncedOnResize = $$rAF . throttle ( function ( ) { updatePosition ( ) ; } ) ;
6463
64+ if ( $animate . pin ) $animate . pin ( element , parent ) ;
65+
6566 // Initialize element
6667
6768 setDefaults ( ) ;
6869 manipulateElement ( ) ;
6970 bindEvents ( ) ;
7071
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
7374 updateContentOrigin ( ) ;
7475
7576 configureWatchers ( ) ;
@@ -81,7 +82,7 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
8182 }
8283
8384 function updateContentOrigin ( ) {
84- var origin = 'left top' ;
85+ var origin = 'center top' ;
8586 switch ( scope . direction ) {
8687 case 'left' : origin = 'right center' ; break ;
8788 case 'right' : origin = 'left center' ; break ;
@@ -137,19 +138,25 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
137138 } ) ;
138139
139140 attributeObserver . observe ( parent [ 0 ] , { attributes : true } ) ;
140- } ;
141+ }
141142
142143 // Store whether the element was focused when the window loses focus.
143144 var windowBlurHandler = function ( ) {
144145 elementFocusedOnWindowBlur = document . activeElement === parent [ 0 ] ;
145146 } ;
146147 var elementFocusedOnWindowBlur = false ;
147148
149+ function windowScrollHandler ( ) {
150+ setVisible ( false ) ;
151+ }
152+
148153 ngWindow . on ( 'blur' , windowBlurHandler ) ;
149154 ngWindow . on ( 'resize' , debouncedOnResize ) ;
155+ document . addEventListener ( 'scroll' , windowScrollHandler , true ) ;
150156 scope . $on ( '$destroy' , function ( ) {
151157 ngWindow . off ( 'blur' , windowBlurHandler ) ;
152158 ngWindow . off ( 'resize' , debouncedOnResize ) ;
159+ document . removeEventListener ( 'scroll' , windowScrollHandler , true ) ;
153160 attributeObserver && attributeObserver . disconnect ( ) ;
154161 } ) ;
155162
0 commit comments