@@ -10,13 +10,22 @@ 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
12
import { Location } from '@angular/common' ;
13
- import { Observable , Subject , merge , SubscriptionLike , Subscription , Observer } from 'rxjs' ;
14
- import { take , takeUntil } from 'rxjs/operators' ;
13
+ import {
14
+ Observable ,
15
+ Subject ,
16
+ merge ,
17
+ SubscriptionLike ,
18
+ Subscription ,
19
+ Observer ,
20
+ fromEvent ,
21
+ } from 'rxjs' ;
22
+ import { take , takeUntil , tap , debounceTime } from 'rxjs/operators' ;
15
23
import { OverlayKeyboardDispatcher } from './keyboard/overlay-keyboard-dispatcher' ;
16
24
import { OverlayConfig } from './overlay-config' ;
17
25
import { coerceCssPixelValue , coerceArray } from '@angular/cdk/coercion' ;
18
26
import { OverlayReference } from './overlay-reference' ;
19
27
import { PositionStrategy } from './position/position-strategy' ;
28
+ import { BlockScrollStrategy } from './scroll/block-scroll-strategy' ;
20
29
21
30
22
31
/** An object where all of its properties cannot be written. */
@@ -364,6 +373,19 @@ export class OverlayRef implements PortalOutlet, OverlayReference {
364
373
this . _backdropElement . addEventListener ( 'click' ,
365
374
( event : MouseEvent ) => this . _backdropClick . next ( event ) ) ;
366
375
376
+ if ( ! ( this . _config . scrollStrategy instanceof BlockScrollStrategy ) ) {
377
+ // When the user starts scrolling by mouse, disable pointer events on the backdrop. This
378
+ // allows for non-body scroll containers (e.g. a sidenav container), which would normally
379
+ // be blocked due to the backdrop, to scroll. When the user has stopped scrolling for 100ms
380
+ // restore the pointer events in order for the click handler to work.
381
+ this . _ngZone . runOutsideAngular ( ( ) => {
382
+ fromEvent ( this . _backdropElement ! , 'wheel' ) . pipe (
383
+ tap ( ( ) => this . _backdropElement ! . style . pointerEvents = 'none' ) ,
384
+ debounceTime ( 100 )
385
+ ) . subscribe ( ( ) => this . _backdropElement ! . style . pointerEvents = '' ) ;
386
+ } ) ;
387
+ }
388
+
367
389
// Add class to fade-in the backdrop after one frame.
368
390
if ( typeof requestAnimationFrame !== 'undefined' ) {
369
391
this . _ngZone . runOutsideAngular ( ( ) => {
0 commit comments