Skip to content

Commit a9d6c52

Browse files
committed
fix tests
1 parent 89b0ab7 commit a9d6c52

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/lib/core/overlay/scroll/scroll-dispatcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'rxjs/add/operator/auditTime';
88

99

1010
/** Time in ms to throttle the scrolling events by default. */
11-
export const DEFAULT_AUDIT_TIME = 20;
11+
export const DEFAULT_SCROLL_TIME = 20;
1212

1313
/**
1414
* Service contained all registered Scrollable references and emits an event when any one of the
@@ -57,7 +57,7 @@ export class ScrollDispatcher {
5757
* references (or window, document, or body) fire a scrolled event. Can provide a time in ms
5858
* to override the default "throttle" time.
5959
*/
60-
scrolled(auditTimeInMs: number = DEFAULT_AUDIT_TIME): Observable<void> {
60+
scrolled(auditTimeInMs: number = DEFAULT_SCROLL_TIME): Observable<void> {
6161
// In the case of a 0ms delay, return the observable without auditTime since it does add
6262
// a perceptible delay in processing overhead.
6363
if (auditTimeInMs == 0) {

src/lib/tooltip/tooltip.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,15 @@ import {Subject} from 'rxjs/Subject';
3434
import {Dir} from '../core/rtl/dir';
3535
import 'rxjs/add/operator/first';
3636
import {ScrollDispatcher} from '../core/overlay/scroll/scroll-dispatcher';
37+
import {Subscription} from 'rxjs';
3738

3839
export type TooltipPosition = 'left' | 'right' | 'above' | 'below' | 'before' | 'after';
3940

4041
/** Time in ms to delay before changing the tooltip visibility to hidden */
4142
export const TOUCHEND_HIDE_DELAY = 1500;
4243

4344
/** Time in ms to throttle repositioning after scroll events. */
44-
export const SCROLL_THROTTLE_MS = 0;
45+
export const SCROLL_THROTTLE_MS = 20;
4546

4647
/**
4748
* 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;
6263
export class MdTooltip implements OnInit, OnDestroy {
6364
_overlayRef: OverlayRef;
6465
_tooltipInstance: TooltipComponent;
66+
scrollSubscription: Subscription;
6567

6668
private _position: TooltipPosition = 'below';
6769

@@ -137,7 +139,7 @@ export class MdTooltip implements OnInit, OnDestroy {
137139
ngOnInit() {
138140
// When a scroll on the page occurs, update the position in case this tooltip needs
139141
// to be repositioned.
140-
this._scrollDispatcher.scrolled(SCROLL_THROTTLE_MS).subscribe(() => {
142+
this.scrollSubscription = this._scrollDispatcher.scrolled(SCROLL_THROTTLE_MS).subscribe(() => {
141143
if (this._overlayRef) {
142144
this._overlayRef.updatePosition();
143145
}
@@ -151,6 +153,8 @@ export class MdTooltip implements OnInit, OnDestroy {
151153
if (this._tooltipInstance) {
152154
this._disposeTooltip();
153155
}
156+
157+
this.scrollSubscription.unsubscribe();
154158
}
155159

156160
/** Shows the tooltip after the delay in ms, defaults to tooltip-delay-show or 0ms if no input */

0 commit comments

Comments
 (0)