@@ -12,8 +12,11 @@ import {normalizePassiveListenerOptions} from '@angular/cdk/platform';
12
12
import { Subject } from 'rxjs' ;
13
13
import { toggleNativeDragInteractions } from './drag-styling' ;
14
14
15
- /** Event options that can be used to bind an active event. */
16
- const activeEventOptions = normalizePassiveListenerOptions ( { passive : false } ) ;
15
+ /** Event options that can be used to bind an active, capturing event. */
16
+ const activeCapturingEventOptions = normalizePassiveListenerOptions ( {
17
+ passive : false ,
18
+ capture : true
19
+ } ) ;
17
20
18
21
/** Handler for a pointer event callback. */
19
22
type PointerEventHandler = ( event : TouchEvent | MouseEvent ) => void ;
@@ -42,7 +45,7 @@ export class DragDropRegistry<I, C extends {id: string}> implements OnDestroy {
42
45
/** Keeps track of the event listeners that we've bound to the `document`. */
43
46
private _globalListeners = new Map < 'touchmove' | 'mousemove' | 'touchend' | 'mouseup' , {
44
47
handler : PointerEventHandler ,
45
- options ?: any
48
+ options ?: AddEventListenerOptions | boolean
46
49
} > ( ) ;
47
50
48
51
/**
@@ -83,7 +86,7 @@ export class DragDropRegistry<I, C extends {id: string}> implements OnDestroy {
83
86
// The event handler has to be explicitly active, because
84
87
// newer browsers make it passive by default.
85
88
this . _document . addEventListener ( 'touchmove' , this . _preventScrollListener ,
86
- activeEventOptions ) ;
89
+ activeCapturingEventOptions ) ;
87
90
} ) ;
88
91
}
89
92
}
@@ -100,7 +103,7 @@ export class DragDropRegistry<I, C extends {id: string}> implements OnDestroy {
100
103
101
104
if ( this . _dragInstances . size === 0 ) {
102
105
this . _document . removeEventListener ( 'touchmove' , this . _preventScrollListener ,
103
- activeEventOptions as any ) ;
106
+ activeCapturingEventOptions ) ;
104
107
}
105
108
}
106
109
@@ -125,8 +128,14 @@ export class DragDropRegistry<I, C extends {id: string}> implements OnDestroy {
125
128
// passive ones for `mousemove` and `touchmove`. The events need to be active, because we
126
129
// use `preventDefault` to prevent the page from scrolling while the user is dragging.
127
130
this . _globalListeners
128
- . set ( moveEvent , { handler : e => this . pointerMove . next ( e ) , options : activeEventOptions } )
129
- . set ( upEvent , { handler : e => this . pointerUp . next ( e ) } )
131
+ . set ( moveEvent , {
132
+ handler : e => this . pointerMove . next ( e ) ,
133
+ options : activeCapturingEventOptions
134
+ } )
135
+ . set ( upEvent , {
136
+ handler : e => this . pointerUp . next ( e ) ,
137
+ options : true
138
+ } )
130
139
. forEach ( ( config , name ) => {
131
140
this . _ngZone . runOutsideAngular ( ( ) => {
132
141
this . _document . addEventListener ( name , config . handler , config . options ) ;
0 commit comments