Skip to content

Commit ed7055e

Browse files
committed
fix tests
1 parent 42783ba commit ed7055e

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
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.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ describe('MdTooltip', () => {
313313
tooltipDirective = buttonDebugElement.injector.get(MdTooltip);
314314
});
315315

316-
it('should hide tooltip if clipped after changing positions', fakeAsync(() => {
316+
fit('should hide tooltip if clipped after changing positions', fakeAsync(() => {
317317
expect(tooltipDirective._tooltipInstance).toBeUndefined();
318318

319319
// Show the tooltip and tick for the show delay (default is 0)

src/lib/tooltip/tooltip.ts

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

3637
export type TooltipPosition = 'left' | 'right' | 'above' | 'below' | 'before' | 'after';
3738

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

4142
/** Time in ms to throttle repositioning after scroll events. */
42-
export const SCROLL_THROTTLE_MS = 0;
43+
export const SCROLL_THROTTLE_MS = 20;
4344

4445
/**
4546
* 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;
6061
export class MdTooltip implements OnInit, OnDestroy {
6162
_overlayRef: OverlayRef;
6263
_tooltipInstance: TooltipComponent;
64+
scrollSubscription: Subscription;
6365

6466
private _position: TooltipPosition = 'below';
6567

@@ -135,7 +137,7 @@ export class MdTooltip implements OnInit, OnDestroy {
135137
ngOnInit() {
136138
// When a scroll on the page occurs, update the position in case this tooltip needs
137139
// to be repositioned.
138-
this._scrollDispatcher.scrolled(SCROLL_THROTTLE_MS).subscribe(() => {
140+
this.scrollSubscription = this._scrollDispatcher.scrolled(SCROLL_THROTTLE_MS).subscribe(() => {
139141
if (this._overlayRef) {
140142
this._overlayRef.updatePosition();
141143
}
@@ -149,6 +151,8 @@ export class MdTooltip implements OnInit, OnDestroy {
149151
if (this._tooltipInstance) {
150152
this._disposeTooltip();
151153
}
154+
155+
this.scrollSubscription.unsubscribe();
152156
}
153157

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

0 commit comments

Comments
 (0)