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