|
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 {Directionality} from '@angular/cdk/bidi';
|
12 | 11 | import {normalizePassiveListenerOptions} from '@angular/cdk/platform';
|
13 | 12 | import {coerceBooleanProperty} from '@angular/cdk/coercion';
|
@@ -267,7 +266,6 @@ export class DragRef<T = any> {
|
267 | 266 | private _document: Document,
|
268 | 267 | private _ngZone: NgZone,
|
269 | 268 | private _viewContainerRef: ViewContainerRef,
|
270 |
| - private _viewportRuler: ViewportRuler, |
271 | 269 | private _dragDropRegistry: DragDropRegistry<DragRef, DropListRef>,
|
272 | 270 | private _config: DragRefConfig,
|
273 | 271 | /** Droppable container that the draggable is a part of. */
|
@@ -630,7 +628,12 @@ export class DragRef<T = any> {
|
630 | 628 | this._initialContainer = this.dropContainer!;
|
631 | 629 | this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
|
632 | 630 | this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
|
633 |
| - this._scrollPosition = this._viewportRuler.getViewportScrollPosition(); |
| 631 | + |
| 632 | + // Note that we use the scrollX and scrollY directly, instead of going through the |
| 633 | + // ViewportRuler, because the first value the ruler looks at is the top/left offset of the |
| 634 | + // `document.documentElement` which works for most cases, but breaks if the element |
| 635 | + // is offset by something like the `BlockScrollStrategy`. |
| 636 | + this._scrollPosition = {top: window.scrollY, left: window.scrollX}; |
634 | 637 |
|
635 | 638 | if (this._boundaryElement) {
|
636 | 639 | this._boundaryRect = this._boundaryElement.getBoundingClientRect();
|
|
0 commit comments