|
9 | 9 | import {Direction, Directionality} from '@angular/cdk/bidi';
|
10 | 10 | import {ComponentPortal, Portal, PortalOutlet, TemplatePortal} from '@angular/cdk/portal';
|
11 | 11 | import {ComponentRef, EmbeddedViewRef, NgZone} from '@angular/core';
|
12 |
| -import {Observable, Subject} from 'rxjs'; |
13 |
| -import {take} from 'rxjs/operators'; |
| 12 | +import {Observable, Subject, fromEvent} from 'rxjs'; |
| 13 | +import {take, tap, debounceTime} from 'rxjs/operators'; |
14 | 14 | import {OverlayKeyboardDispatcher} from './keyboard/overlay-keyboard-dispatcher';
|
15 | 15 | import {OverlayConfig} from './overlay-config';
|
16 | 16 | import {coerceCssPixelValue, coerceArray} from '@angular/cdk/coercion';
|
17 | 17 | import {OverlayReference} from './overlay-reference';
|
| 18 | +import {BlockScrollStrategy} from './scroll/index'; |
18 | 19 |
|
19 | 20 |
|
20 | 21 | /** An object where all of its properties cannot be written. */
|
@@ -316,6 +317,19 @@ export class OverlayRef implements PortalOutlet, OverlayReference {
|
316 | 317 | this._backdropElement.addEventListener('click',
|
317 | 318 | (event: MouseEvent) => this._backdropClick.next(event));
|
318 | 319 |
|
| 320 | + if (!(this._config.scrollStrategy instanceof BlockScrollStrategy)) { |
| 321 | + // When the user starts scrolling by mouse, disable pointer events on the backdrop. This |
| 322 | + // allows for non-body scroll containers (e.g. a sidenav container), which would normally |
| 323 | + // be blocked due to the backdrop, to scroll. When the user has stopped scrolling for 100ms |
| 324 | + // restore the pointer events in order for the click handler to work. |
| 325 | + this._ngZone.runOutsideAngular(() => { |
| 326 | + fromEvent(this._backdropElement!, 'wheel').pipe( |
| 327 | + tap(() => this._backdropElement!.style.pointerEvents = 'none'), |
| 328 | + debounceTime(100) |
| 329 | + ).subscribe(() => this._backdropElement!.style.pointerEvents = ''); |
| 330 | + }); |
| 331 | + } |
| 332 | + |
319 | 333 | // Add class to fade-in the backdrop after one frame.
|
320 | 334 | if (typeof requestAnimationFrame !== 'undefined') {
|
321 | 335 | this._ngZone.runOutsideAngular(() => {
|
|
0 commit comments