Skip to content

Commit a87a000

Browse files
mmalerbaandrewseguin
authored andcommitted
fix(slider): work around slidestart event sometimes not firing on iOS (#6009)
1 parent ee73d2c commit a87a000

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/lib/slider/slider.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,12 @@ export class MdSlider extends _MdSliderMixinBase
452452
return;
453453
}
454454

455+
// The slide start event sometimes fails to fire on iOS, so if we're not already in the sliding
456+
// state, call the slide start handler manually.
457+
if (!this._isSliding) {
458+
this._onSlideStart(null);
459+
}
460+
455461
// Prevent the slide from selecting anything else.
456462
event.preventDefault();
457463
this._updateValueFromPosition({x: event.center.x, y: event.center.y});
@@ -460,18 +466,21 @@ export class MdSlider extends _MdSliderMixinBase
460466
this._emitInputEvent();
461467
}
462468

463-
_onSlideStart(event: HammerInput) {
469+
_onSlideStart(event: HammerInput | null) {
464470
if (this.disabled) {
465471
return;
466472
}
467473

468474
// Simulate mouseenter in case this is a mobile device.
469475
this._onMouseenter();
470476

471-
event.preventDefault();
472477
this._isSliding = true;
473478
this._renderer.addFocus();
474-
this._updateValueFromPosition({x: event.center.x, y: event.center.y});
479+
480+
if (event) {
481+
this._updateValueFromPosition({x: event.center.x, y: event.center.y});
482+
event.preventDefault();
483+
}
475484
}
476485

477486
_onSlideEnd() {

0 commit comments

Comments
 (0)