|
7 | 7 | */
|
8 | 8 |
|
9 | 9 | import {EmbeddedViewRef, ElementRef, NgZone, ViewContainerRef, TemplateRef} from '@angular/core';
|
10 |
| -import {ViewportRuler} from '@angular/cdk/scrolling'; |
11 | 10 | import {Direction} from '@angular/cdk/bidi';
|
12 | 11 | import {normalizePassiveListenerOptions} from '@angular/cdk/platform';
|
13 | 12 | import {coerceBooleanProperty, coerceElement} from '@angular/cdk/coercion';
|
@@ -269,7 +268,6 @@ export class DragRef<T = any> {
|
269 | 268 | private _config: DragRefConfig,
|
270 | 269 | private _document: Document,
|
271 | 270 | private _ngZone: NgZone,
|
272 |
| - private _viewportRuler: ViewportRuler, |
273 | 271 | private _dragDropRegistry: DragDropRegistry<DragRef, DropListRef>) {
|
274 | 272 |
|
275 | 273 | this.withRootElement(element);
|
@@ -661,7 +659,12 @@ export class DragRef<T = any> {
|
661 | 659 | this._initialContainer = this._dropContainer!;
|
662 | 660 | this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
|
663 | 661 | this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
|
664 |
| - this._scrollPosition = this._viewportRuler.getViewportScrollPosition(); |
| 662 | + |
| 663 | + // Note that we use the scrollX and scrollY directly, instead of going through the |
| 664 | + // ViewportRuler, because the first value the ruler looks at is the top/left offset of the |
| 665 | + // `document.documentElement` which works for most cases, but breaks if the element |
| 666 | + // is offset by something like the `BlockScrollStrategy`. |
| 667 | + this._scrollPosition = {top: window.scrollY, left: window.scrollX}; |
665 | 668 |
|
666 | 669 | if (this._boundaryElement) {
|
667 | 670 | this._boundaryRect = this._boundaryElement.getBoundingClientRect();
|
|
0 commit comments