@@ -34,14 +34,15 @@ import {Subject} from 'rxjs/Subject';
34
34
import { Dir } from '../core/rtl/dir' ;
35
35
import 'rxjs/add/operator/first' ;
36
36
import { ScrollDispatcher } from '../core/overlay/scroll/scroll-dispatcher' ;
37
+ import { Subscription } from 'rxjs' ;
37
38
38
39
export type TooltipPosition = 'left' | 'right' | 'above' | 'below' | 'before' | 'after' ;
39
40
40
41
/** Time in ms to delay before changing the tooltip visibility to hidden */
41
42
export const TOUCHEND_HIDE_DELAY = 1500 ;
42
43
43
44
/** Time in ms to throttle repositioning after scroll events. */
44
- export const SCROLL_THROTTLE_MS = 0 ;
45
+ export const SCROLL_THROTTLE_MS = 20 ;
45
46
46
47
/**
47
48
* Directive that attaches a material design tooltip to the host element. Animates the showing and
@@ -62,6 +63,7 @@ export const SCROLL_THROTTLE_MS = 0;
62
63
export class MdTooltip implements OnInit , OnDestroy {
63
64
_overlayRef : OverlayRef ;
64
65
_tooltipInstance : TooltipComponent ;
66
+ scrollSubscription : Subscription ;
65
67
66
68
private _position : TooltipPosition = 'below' ;
67
69
@@ -137,7 +139,7 @@ export class MdTooltip implements OnInit, OnDestroy {
137
139
ngOnInit ( ) {
138
140
// When a scroll on the page occurs, update the position in case this tooltip needs
139
141
// to be repositioned.
140
- this . _scrollDispatcher . scrolled ( SCROLL_THROTTLE_MS ) . subscribe ( ( ) => {
142
+ this . scrollSubscription = this . _scrollDispatcher . scrolled ( SCROLL_THROTTLE_MS ) . subscribe ( ( ) => {
141
143
if ( this . _overlayRef ) {
142
144
this . _overlayRef . updatePosition ( ) ;
143
145
}
@@ -151,6 +153,8 @@ export class MdTooltip implements OnInit, OnDestroy {
151
153
if ( this . _tooltipInstance ) {
152
154
this . _disposeTooltip ( ) ;
153
155
}
156
+
157
+ this . scrollSubscription . unsubscribe ( ) ;
154
158
}
155
159
156
160
/** Shows the tooltip after the delay in ms, defaults to tooltip-delay-show or 0ms if no input */
0 commit comments