@@ -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,38 @@ 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+ this . _elementRef . nativeElement . addEventListener ( evtType , handler , activeListenerOptions ) ,
236239 deregisterInteractionHandler : ( evtType , handler ) =>
237240 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+ } ,
250253 registerBodyInteractionHandler : ( evtType , handler ) =>
251254 // Body event handlers (which handle thumb sliding) cannot be passive as they will
252255 // prevent the default behavior. Additionally we can't run these event handlers
253256 // outside of the Angular zone because we rely on the events to cause the component
254257 // tree to be re-checked.
255- document . body . addEventListener ( evtType , handler ) ,
258+ document . body . addEventListener ( evtType , handler ) ,
256259 deregisterBodyInteractionHandler : ( evtType , handler ) =>
257260 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+ } ,
266268 deregisterResizeHandler : ( handler ) =>
267- window . removeEventListener ( 'resize' , handler , listenerOptions ) ,
269+ window . removeEventListener ( 'resize' , handler , passiveListenerOptions ) ,
268270 notifyInput :
269271 ( ) => {
270272 const newValue = this . _foundation . getValue ( ) ;
0 commit comments