Skip to content

Commit c88c6bc

Browse files
committed
Updates for IE11
1 parent ee29e60 commit c88c6bc

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ describe('ViewportRuler', () => {
4040

4141
it('should get the viewport bounds when the page is scrolled', () => {
4242
document.body.appendChild(veryLargeElement);
43+
4344
scrollTo(1500, 2000);
45+
ruler.updateDocumentRectangle();
4446

4547
let bounds = ruler.getViewportRect();
4648

@@ -68,14 +70,16 @@ describe('ViewportRuler', () => {
6870
});
6971

7072
it('should get the scroll position when the page is not scrolled', () => {
71-
var scrollPos = ruler.getViewportScrollPosition();
73+
let scrollPos = ruler.getViewportScrollPosition();
7274
expect(scrollPos.top).toBe(0);
7375
expect(scrollPos.left).toBe(0);
7476
});
7577

7678
it('should get the scroll position when the page is scrolled', () => {
7779
document.body.appendChild(veryLargeElement);
80+
7881
scrollTo(1500, 2000);
82+
ruler.updateDocumentRectangle();
7983

8084
// In the iOS simulator (BrowserStack & SauceLabs), adding the content to the
8185
// body causes karma's iframe for the test to stretch to fit that content once we attempt to
@@ -87,7 +91,7 @@ describe('ViewportRuler', () => {
8791
return;
8892
}
8993

90-
var scrollPos = ruler.getViewportScrollPosition();
94+
let scrollPos = ruler.getViewportScrollPosition();
9195
expect(scrollPos.top).toBe(2000);
9296
expect(scrollPos.left).toBe(1500);
9397

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ export class ViewportRuler {
1616
constructor(scrollDispatcher: ScrollDispatcher) {
1717

1818
// Initially update the document rectangle.
19-
this._updateDocumentRect();
19+
this.updateDocumentRectangle();
2020

2121
// Subscribe to scroll and resize events and update the document rectangle on changes.
2222
scrollDispatcher
2323
.scrolled()
24-
.subscribe(() => this._updateDocumentRect());
24+
.subscribe(() => this.updateDocumentRectangle());
2525
}
2626

2727
/** Gets a ClientRect for the viewport's bounds. */
@@ -67,8 +67,11 @@ export class ViewportRuler {
6767
return {top, left};
6868
}
6969

70-
/** Updates the cached client rectangle of the document element.*/
71-
private _updateDocumentRect() {
70+
/**
71+
* @internal
72+
* Updates the cached client rectangle of the document element.
73+
*/
74+
updateDocumentRectangle() {
7275
this._documentRect = document.documentElement.getBoundingClientRect();
7376
}
7477

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import {TestBed, ComponentFixture, fakeAsync, tick} from '@angular/core/testing';
1+
import {TestBed, ComponentFixture, fakeAsync, tick, inject} from '@angular/core/testing';
22
import {Component, ViewChild} from '@angular/core';
33
import {MdRipple, MdRippleModule} from './ripple';
4+
import {ViewportRuler} from '../overlay/position/viewport-ruler';
45

56

67
/** Creates a DOM event to indicate that a CSS transition for the given property ended. */
@@ -60,6 +61,7 @@ describe('MdRipple', () => {
6061
let rippleElement: HTMLElement;
6162
let rippleBackground: Element;
6263
let originalBodyMargin: string;
64+
let viewportRuler: ViewportRuler;
6365

6466
beforeEach(() => {
6567
TestBed.configureTestingModule({
@@ -72,11 +74,13 @@ describe('MdRipple', () => {
7274
});
7375
});
7476

75-
beforeEach(() => {
77+
beforeEach(inject([ViewportRuler], (ruler: ViewportRuler) => {
78+
viewportRuler = ruler;
79+
7680
// Set body margin to 0 during tests so it doesn't mess up position calculations.
7781
originalBodyMargin = document.body.style.margin;
7882
document.body.style.margin = '0';
79-
});
83+
}));
8084

8185
afterEach(() => {
8286
document.body.style.margin = originalBodyMargin;
@@ -228,6 +232,8 @@ describe('MdRipple', () => {
228232
document.documentElement.scrollTop = pageScrollTop;
229233
// Mobile safari
230234
window.scrollTo(pageScrollLeft, pageScrollTop);
235+
// Force an update of the cached rectangle in the ViewportRuler.
236+
viewportRuler.updateDocumentRectangle();
231237
});
232238

233239
afterEach(() => {
@@ -239,6 +245,8 @@ describe('MdRipple', () => {
239245
document.documentElement.scrollTop = 0;
240246
// Mobile safari
241247
window.scrollTo(0, 0);
248+
// Force an update of the cached rectangle in the ViewportRuler.
249+
viewportRuler.updateDocumentRectangle();
242250
});
243251

244252
it('create ripple with correct position', () => {

0 commit comments

Comments
 (0)