@@ -680,9 +680,7 @@ export class MatSlider extends _MatSliderMixinBase
680
680
this . _foundation . destroy ( ) ;
681
681
}
682
682
this . _dirChangeSubscription . unsubscribe ( ) ;
683
-
684
- const evtType = this . _getEventTypeTypeForUISyncEventListener ( ) ;
685
- this . _elementRef . nativeElement . removeEventListener ( evtType , this . _layout ) ;
683
+ this . _removeUISyncEventListener ( ) ;
686
684
}
687
685
688
686
/** Returns true if the language direction for this slider element is right to left. */
@@ -703,19 +701,16 @@ export class MatSlider extends _MatSliderMixinBase
703
701
// "mousedown" as the default for when a browser does not support pointer events. While we
704
702
// would prefer to use "mousedown" as the default, for some reason it does not work (the
705
703
// callback is never triggered).
706
- const evtType = this . _getEventTypeTypeForUISyncEventListener ( ) ;
704
+ const evtType = this . _SUPPORTS_POINTER_EVENTS ? 'pointerdown' : 'mouseenter' ;
707
705
this . _elementRef . nativeElement . addEventListener ( evtType , this . _layout ) ;
706
+ this . _elementRef . nativeElement . addEventListener ( 'touchstart' , this . _layout ) ;
708
707
}
709
708
710
- /** Returns the event type that should be used for syncing the slider UI with the foundation. */
711
- private _getEventTypeTypeForUISyncEventListener ( ) : string {
712
- if ( this . _SUPPORTS_POINTER_EVENTS ) {
713
- return 'pointerdown' ;
714
- }
715
- if ( this . _platform . isBrowser ) {
716
- return 'mousedown' ;
717
- }
718
- return 'touchstart' ;
709
+ /** Removes the event listener that keeps sync the slider UI and the foundation in sync. */
710
+ _removeUISyncEventListener ( ) : void {
711
+ const evtType = this . _SUPPORTS_POINTER_EVENTS ? 'pointerdown' : 'mouseenter' ;
712
+ this . _elementRef . nativeElement . removeEventListener ( evtType , this . _layout ) ;
713
+ this . _elementRef . nativeElement . removeEventListener ( 'touchstart' , this . _layout ) ;
719
714
}
720
715
721
716
/** Wrapper function for calling layout (needed for adding & removing an event listener). */
0 commit comments