@@ -53,8 +53,11 @@ const MIN_AUTO_TICK_SEPARATION = 30;
53
53
*/
54
54
const TICK_MARKER_SIZE = 2 ;
55
55
56
- /** Options to pass to the slider interaction listeners. */
57
- const listenerOptions = normalizePassiveListenerOptions ( { passive : true } ) ;
56
+ /** Event options used to bind passive listeners. */
57
+ const passiveListenerOptions = normalizePassiveListenerOptions ( { passive : true } ) ;
58
+
59
+ /** Event options used to bind active listeners. */
60
+ const activeListenerOptions = normalizePassiveListenerOptions ( { passive : false } ) ;
58
61
59
62
/**
60
63
* Provider Expression that allows mat-slider to register as a ControlValueAccessor.
@@ -232,39 +235,38 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
232
235
// as they will prevent the default behavior. Additionally we can't run these event
233
236
// handlers outside of the Angular zone because we rely on the events to cause the
234
237
// component tree to be re-checked.
235
- this . _elementRef . nativeElement . addEventListener ( evtType , handler ) ,
238
+ this . _elementRef . nativeElement . addEventListener ( evtType , handler , activeListenerOptions ) ,
236
239
deregisterInteractionHandler : ( evtType , handler ) =>
237
240
this . _elementRef . nativeElement . removeEventListener ( evtType , handler ) ,
238
- registerThumbContainerInteractionHandler :
239
- ( evtType , handler ) => {
240
- // The thumb container interaction handlers are currently just used for transition
241
- // events which don't need to run in the Angular zone.
242
- this . _ngZone . runOutsideAngular ( ( ) => {
243
- this . _thumbContainer . nativeElement . addEventListener ( evtType , handler , listenerOptions ) ;
244
- } ) ;
245
- } ,
246
- deregisterThumbContainerInteractionHandler :
247
- ( evtType , handler ) => {
248
- this . _thumbContainer . nativeElement . removeEventListener ( evtType , handler , listenerOptions ) ;
249
- } ,
241
+ registerThumbContainerInteractionHandler : ( evtType , handler ) => {
242
+ // The thumb container interaction handlers are currently just used for transition
243
+ // events which don't need to run in the Angular zone.
244
+ this . _ngZone . runOutsideAngular ( ( ) => {
245
+ this . _thumbContainer . nativeElement
246
+ . addEventListener ( evtType , handler , passiveListenerOptions ) ;
247
+ } ) ;
248
+ } ,
249
+ deregisterThumbContainerInteractionHandler : ( evtType , handler ) => {
250
+ this . _thumbContainer . nativeElement
251
+ . removeEventListener ( evtType , handler , passiveListenerOptions ) ;
252
+ } ,
250
253
registerBodyInteractionHandler : ( evtType , handler ) =>
251
254
// Body event handlers (which handle thumb sliding) cannot be passive as they will
252
255
// prevent the default behavior. Additionally we can't run these event handlers
253
256
// outside of the Angular zone because we rely on the events to cause the component
254
257
// tree to be re-checked.
255
- document . body . addEventListener ( evtType , handler ) ,
258
+ document . body . addEventListener ( evtType , handler ) ,
256
259
deregisterBodyInteractionHandler : ( evtType , handler ) =>
257
260
document . body . removeEventListener ( evtType , handler ) ,
258
- registerResizeHandler :
259
- ( handler ) => {
260
- // The resize handler is currently responsible for detecting slider dimension
261
- // changes and therefore doesn't cause a value change that needs to be propagated.
262
- this . _ngZone . runOutsideAngular ( ( ) => {
263
- window . addEventListener ( 'resize' , handler , listenerOptions ) ;
264
- } ) ;
265
- } ,
261
+ registerResizeHandler : ( handler ) => {
262
+ // The resize handler is currently responsible for detecting slider dimension
263
+ // changes and therefore doesn't cause a value change that needs to be propagated.
264
+ this . _ngZone . runOutsideAngular ( ( ) => {
265
+ window . addEventListener ( 'resize' , handler , passiveListenerOptions ) ;
266
+ } ) ;
267
+ } ,
266
268
deregisterResizeHandler : ( handler ) =>
267
- window . removeEventListener ( 'resize' , handler , listenerOptions ) ,
269
+ window . removeEventListener ( 'resize' , handler , passiveListenerOptions ) ,
268
270
notifyInput :
269
271
( ) => {
270
272
const newValue = this . _foundation . getValue ( ) ;
0 commit comments