Skip to content

Commit 03712ef

Browse files
committed
fixup! fix(material-experimental/mdc-slider): sync ui on mouseenter
1 parent efa4a37 commit 03712ef

File tree

1 file changed

+8
-13
lines changed
  • src/material-experimental/mdc-slider

1 file changed

+8
-13
lines changed

src/material-experimental/mdc-slider/slider.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,7 @@ export class MatSlider extends _MatSliderMixinBase
680680
this._foundation.destroy();
681681
}
682682
this._dirChangeSubscription.unsubscribe();
683-
684-
const evtType = this._getEventTypeTypeForUISyncEventListener();
685-
this._elementRef.nativeElement.removeEventListener(evtType, this._layout);
683+
this._removeUISyncEventListener();
686684
}
687685

688686
/** Returns true if the language direction for this slider element is right to left. */
@@ -703,19 +701,16 @@ export class MatSlider extends _MatSliderMixinBase
703701
// "mousedown" as the default for when a browser does not support pointer events. While we
704702
// would prefer to use "mousedown" as the default, for some reason it does not work (the
705703
// callback is never triggered).
706-
const evtType = this._getEventTypeTypeForUISyncEventListener();
704+
const evtType = this._SUPPORTS_POINTER_EVENTS ? 'pointerdown' : 'mouseenter';
707705
this._elementRef.nativeElement.addEventListener(evtType, this._layout);
706+
this._elementRef.nativeElement.addEventListener('touchstart', this._layout);
708707
}
709708

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);
719714
}
720715

721716
/** Wrapper function for calling layout (needed for adding & removing an event listener). */

0 commit comments

Comments
 (0)