Skip to content

Commit 359ce84

Browse files
committed
fix scroll dispatcher circular dep
1 parent 89a4108 commit 359ce84

9 files changed

+55
-46
lines changed

src/lib/core/overlay/overlay-directives.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {coerceBooleanProperty} from '../coercion/boolean-property';
2929
import {ESCAPE} from '../keyboard/keycodes';
3030
import {ScrollDispatcher} from './scroll/scroll-dispatcher';
3131
import {Subscription} from 'rxjs/Subscription';
32-
import {ScrollDispatchModule} from './scroll/scroll-dispatcher';
32+
import {ScrollDispatchModule} from './scroll/index';
3333

3434

3535
/** Default set of positions for the overlay. Follows the behavior of a dropdown. */

src/lib/core/overlay/position/connected-position-strategy.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {Scrollable} from '../scroll/scrollable';
77
import {Subscription} from 'rxjs/Subscription';
88
import {TestBed, inject} from '@angular/core/testing';
99
import Spy = jasmine.Spy;
10-
import {ScrollDispatchModule} from '../scroll/scroll-dispatcher';
10+
import {ScrollDispatchModule} from '../scroll/index';
1111

1212

1313
// Default width and height of the overlay and origin panels throughout these tests.

src/lib/core/overlay/position/viewport-ruler.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {ViewportRuler, VIEWPORT_RULER_PROVIDER} from './viewport-ruler';
22
import {TestBed, inject} from '@angular/core/testing';
3-
import {ScrollDispatchModule} from '../scroll/scroll-dispatcher';
3+
import {ScrollDispatchModule} from '../scroll/index';
44

55

66
// For all tests, we assume the browser window is 1024x786 (outerWidth x outerHeight).

src/lib/core/overlay/scroll/index.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {NgModule} from '@angular/core';
2+
import {SCROLL_DISPATCHER_PROVIDER} from './scroll-dispatcher';
3+
import {Scrollable} from './scrollable';
4+
import {PlatformModule} from '../../platform/index';
5+
6+
export {Scrollable} from './scrollable';
7+
export {ScrollDispatcher} from './scroll-dispatcher';
8+
9+
@NgModule({
10+
imports: [PlatformModule],
11+
exports: [Scrollable],
12+
declarations: [Scrollable],
13+
providers: [SCROLL_DISPATCHER_PROVIDER],
14+
})
15+
export class ScrollDispatchModule { }

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

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {NgModule, ElementRef, Injectable, NgZone, Optional, SkipSelf} from '@angular/core';
2-
import {Platform, PlatformModule} from '../../platform/index';
1+
import {ElementRef, Injectable, NgZone, Optional, SkipSelf} from '@angular/core';
2+
import {Platform} from '../../platform/index';
33
import {Scrollable} from './scrollable';
44
import {Subject} from 'rxjs/Subject';
55
import {Observable} from 'rxjs/Observable';
@@ -143,12 +143,3 @@ export const SCROLL_DISPATCHER_PROVIDER = {
143143
deps: [[new Optional(), new SkipSelf(), ScrollDispatcher], NgZone, Platform],
144144
useFactory: SCROLL_DISPATCHER_PROVIDER_FACTORY
145145
};
146-
147-
148-
@NgModule({
149-
imports: [PlatformModule],
150-
exports: [Scrollable],
151-
declarations: [Scrollable],
152-
providers: [SCROLL_DISPATCHER_PROVIDER],
153-
})
154-
export class ScrollDispatchModule { }

src/lib/core/ripple/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {NgModule} from '@angular/core';
22
import {MdRipple} from './ripple';
33
import {MdCommonModule} from '../common-behaviors/common-module';
44
import {VIEWPORT_RULER_PROVIDER} from '../overlay/position/viewport-ruler';
5-
import {ScrollDispatchModule} from '../overlay/scroll/scroll-dispatcher';
5+
import {ScrollDispatchModule} from '../overlay/scroll/index';
66
import {PlatformModule} from '../platform/index';
77

88
export {MdRipple, RippleGlobalOptions, MD_RIPPLE_GLOBAL_OPTIONS} from './ripple';

src/lib/core/ripple/ripple.spec.ts

+28-29
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,34 @@ describe('MdRipple', () => {
5656
rippleDirective = fixture.componentInstance.ripple;
5757
});
5858

59+
it('sizes ripple to cover element', () => {
60+
let elementRect = rippleTarget.getBoundingClientRect();
61+
62+
// Dispatch a ripple at the following relative coordinates (X: 50| Y: 75)
63+
dispatchMouseEvent(rippleTarget, 'mousedown', 50, 75);
64+
dispatchMouseEvent(rippleTarget, 'mouseup');
65+
66+
// Calculate distance from the click to farthest edge of the ripple target.
67+
let maxDistanceX = TARGET_WIDTH - 50;
68+
let maxDistanceY = TARGET_HEIGHT - 75;
69+
70+
// At this point the foreground ripple should be created with a div centered at the click
71+
// location, and large enough to reach the furthest corner, which is 250px to the right
72+
// and 125px down relative to the click position.
73+
let expectedRadius = Math.sqrt(maxDistanceX * maxDistanceX + maxDistanceY * maxDistanceY);
74+
let expectedLeft = elementRect.left + 50 - expectedRadius;
75+
let expectedTop = elementRect.top + 75 - expectedRadius;
76+
77+
let ripple = rippleTarget.querySelector('.mat-ripple-element') as HTMLElement;
78+
79+
// Note: getBoundingClientRect won't work because there's a transform applied to make the
80+
// ripple start out tiny.
81+
expect(pxStringToFloat(ripple.style.left)).toBeCloseTo(expectedLeft, 1);
82+
expect(pxStringToFloat(ripple.style.top)).toBeCloseTo(expectedTop, 1);
83+
expect(pxStringToFloat(ripple.style.width)).toBeCloseTo(2 * expectedRadius, 1);
84+
expect(pxStringToFloat(ripple.style.height)).toBeCloseTo(2 * expectedRadius, 1);
85+
});
86+
5987
it('creates ripple on mousedown', () => {
6088
dispatchMouseEvent(rippleTarget, 'mousedown');
6189
dispatchMouseEvent(rippleTarget, 'mouseup');
@@ -137,35 +165,6 @@ describe('MdRipple', () => {
137165
expect(parseFloat(rippleElement.style.top)).toBeCloseTo(TARGET_HEIGHT / 2 - radius, 1);
138166
});
139167

140-
it('sizes ripple to cover element', () => {
141-
let elementRect = rippleTarget.getBoundingClientRect();
142-
143-
// Dispatch a ripple at the following relative coordinates (X: 50| Y: 75)
144-
dispatchMouseEvent(rippleTarget, 'mousedown', 50, 75);
145-
dispatchMouseEvent(rippleTarget, 'mouseup');
146-
147-
// Calculate distance from the click to farthest edge of the ripple target.
148-
let maxDistanceX = TARGET_WIDTH - 50;
149-
let maxDistanceY = TARGET_HEIGHT - 75;
150-
151-
// At this point the foreground ripple should be created with a div centered at the click
152-
// location, and large enough to reach the furthest corner, which is 250px to the right
153-
// and 125px down relative to the click position.
154-
let expectedRadius = Math.sqrt(maxDistanceX * maxDistanceX + maxDistanceY * maxDistanceY);
155-
let expectedLeft = elementRect.left + 50 - expectedRadius;
156-
let expectedTop = elementRect.top + 75 - expectedRadius;
157-
158-
let ripple = rippleTarget.querySelector('.mat-ripple-element') as HTMLElement;
159-
160-
// Note: getBoundingClientRect won't work because there's a transform applied to make the
161-
// ripple start out tiny.
162-
expect(pxStringToFloat(ripple.style.left)).toBeCloseTo(expectedLeft, 1);
163-
expect(pxStringToFloat(ripple.style.top)).toBeCloseTo(expectedTop, 1);
164-
expect(pxStringToFloat(ripple.style.width)).toBeCloseTo(2 * expectedRadius, 1);
165-
expect(pxStringToFloat(ripple.style.height)).toBeCloseTo(2 * expectedRadius, 1);
166-
});
167-
168-
169168
it('cleans up the event handlers when the container gets destroyed', () => {
170169
fixture = TestBed.createComponent(RippleContainerWithNgIf);
171170
fixture.detectChanges();

src/lib/core/style/focus-origin-monitor.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ export class FocusOriginMonitor {
6464
* @returns An observable that emits when the focus state of the element changes.
6565
* When the element is blurred, null will be emitted.
6666
*/
67-
monitor(element: HTMLElement, renderer: Renderer2, checkChildren: boolean): Observable<FocusOrigin> {// Do nothing if we're not on the browser platform.
67+
monitor(
68+
element: HTMLElement,
69+
renderer: Renderer2,
70+
checkChildren: boolean): Observable<FocusOrigin> {
71+
// Do nothing if we're not on the browser platform.
6872
if (!this._platform.isBrowser) {
6973
return Observable.of();
7074
}

src/lib/tabs/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {MdInkBar} from './ink-bar';
1212
import {MdTabBody} from './tab-body';
1313
import {VIEWPORT_RULER_PROVIDER} from '../core/overlay/position/viewport-ruler';
1414
import {MdTabHeader} from './tab-header';
15-
import {ScrollDispatchModule} from '../core/overlay/scroll/scroll-dispatcher';
15+
import {ScrollDispatchModule} from '../core/overlay/scroll/index';
1616

1717

1818
@NgModule({

0 commit comments

Comments
 (0)