@@ -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,36 @@ 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
+ // TODO: take in the event listener options from the adapter once MDC supports it.
239
+ this . _elementRef . nativeElement . addEventListener ( evtType , handler , activeListenerOptions ) ,
236
240
deregisterInteractionHandler : ( evtType , handler ) =>
237
241
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
- } ,
242
+ registerThumbContainerInteractionHandler : ( evtType , handler ) => {
243
+ // The thumb container interaction handlers are currently just used for transition
244
+ // events which don't need to run in the Angular zone.
245
+ this . _ngZone . runOutsideAngular ( ( ) => {
246
+ this . _thumbContainer . nativeElement
247
+ . addEventListener ( evtType , handler , passiveListenerOptions ) ;
248
+ } ) ;
249
+ } ,
250
+ deregisterThumbContainerInteractionHandler : ( evtType , handler ) => {
251
+ this . _thumbContainer . nativeElement
252
+ . removeEventListener ( evtType , handler , passiveListenerOptions ) ;
253
+ } ,
250
254
registerBodyInteractionHandler : ( evtType , handler ) =>
251
255
// Body event handlers (which handle thumb sliding) cannot be passive as they will
252
256
// prevent the default behavior. Additionally we can't run these event handlers
253
257
// outside of the Angular zone because we rely on the events to cause the component
254
258
// tree to be re-checked.
255
- document . body . addEventListener ( evtType , handler ) ,
259
+ document . body . addEventListener ( evtType , handler ) ,
256
260
deregisterBodyInteractionHandler : ( evtType , handler ) =>
257
261
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
- } ,
266
- deregisterResizeHandler : ( handler ) =>
267
- window . removeEventListener ( 'resize' , handler , listenerOptions ) ,
262
+ registerResizeHandler : ( handler ) => {
263
+ // The resize handler is currently responsible for detecting slider dimension
264
+ // changes and therefore doesn't cause a value change that needs to be propagated.
265
+ this . _ngZone . runOutsideAngular ( ( ) => window . addEventListener ( 'resize' , handler ) ) ;
266
+ } ,
267
+ deregisterResizeHandler : ( handler ) => window . removeEventListener ( 'resize' , handler ) ,
268
268
notifyInput :
269
269
( ) => {
270
270
const newValue = this . _foundation . getValue ( ) ;
0 commit comments