@@ -53,8 +53,11 @@ const MIN_AUTO_TICK_SEPARATION = 30;
5353 */
5454const TICK_MARKER_SIZE = 2 ;
5555
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 } ) ;
5861
5962/**
6063 * Provider Expression that allows mat-slider to register as a ControlValueAccessor.
@@ -232,39 +235,36 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
232235 // as they will prevent the default behavior. Additionally we can't run these event
233236 // handlers outside of the Angular zone because we rely on the events to cause the
234237 // 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 ) ,
236240 deregisterInteractionHandler : ( evtType , handler ) =>
237241 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+ } ,
250254 registerBodyInteractionHandler : ( evtType , handler ) =>
251255 // Body event handlers (which handle thumb sliding) cannot be passive as they will
252256 // prevent the default behavior. Additionally we can't run these event handlers
253257 // outside of the Angular zone because we rely on the events to cause the component
254258 // tree to be re-checked.
255- document . body . addEventListener ( evtType , handler ) ,
259+ document . body . addEventListener ( evtType , handler ) ,
256260 deregisterBodyInteractionHandler : ( evtType , handler ) =>
257261 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 ) ,
268268 notifyInput :
269269 ( ) => {
270270 const newValue = this . _foundation . getValue ( ) ;
0 commit comments