Skip to content

Commit 0bd666b

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

File tree

1 file changed

+12
-6
lines changed
  • src/material-experimental/mdc-slider

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -701,16 +701,22 @@ export class MatSlider extends _MatSliderMixinBase
701701
// "mousedown" as the default for when a browser does not support pointer events. While we
702702
// would prefer to use "mousedown" as the default, for some reason it does not work (the
703703
// callback is never triggered).
704-
const evtType = this._SUPPORTS_POINTER_EVENTS ? 'pointerdown' : 'mouseenter';
705-
this._elementRef.nativeElement.addEventListener(evtType, this._layout);
706-
this._elementRef.nativeElement.addEventListener('touchstart', this._layout);
704+
if (this._SUPPORTS_POINTER_EVENTS) {
705+
this._elementRef.nativeElement.addEventListener('pointerdown', this._layout);
706+
} else {
707+
this._elementRef.nativeElement.addEventListener('mouseenter', this._layout);
708+
this._elementRef.nativeElement.addEventListener('touchstart', this._layout);
709+
}
707710
}
708711

709712
/** Removes the event listener that keeps sync the slider UI and the foundation in sync. */
710713
_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);
714+
if (this._SUPPORTS_POINTER_EVENTS) {
715+
this._elementRef.nativeElement.removeEventListener('pointerdown', this._layout);
716+
} else {
717+
this._elementRef.nativeElement.removeEventListener('mouseenter', this._layout);
718+
this._elementRef.nativeElement.removeEventListener('touchstart', this._layout);
719+
}
714720
}
715721

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

0 commit comments

Comments
 (0)