Skip to content

Commit

Permalink
fix(slider): work around slidestart event sometimes not firing on iOS (
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba authored and andrewseguin committed Jul 27, 2017
1 parent ee73d2c commit a87a000
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/lib/slider/slider.ts
Expand Up @@ -452,6 +452,12 @@ export class MdSlider extends _MdSliderMixinBase
return;
}

// The slide start event sometimes fails to fire on iOS, so if we're not already in the sliding
// state, call the slide start handler manually.
if (!this._isSliding) {
this._onSlideStart(null);
}

// Prevent the slide from selecting anything else.
event.preventDefault();
this._updateValueFromPosition({x: event.center.x, y: event.center.y});
Expand All @@ -460,18 +466,21 @@ export class MdSlider extends _MdSliderMixinBase
this._emitInputEvent();
}

_onSlideStart(event: HammerInput) {
_onSlideStart(event: HammerInput | null) {
if (this.disabled) {
return;
}

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

event.preventDefault();
this._isSliding = true;
this._renderer.addFocus();
this._updateValueFromPosition({x: event.center.x, y: event.center.y});

if (event) {
this._updateValueFromPosition({x: event.center.x, y: event.center.y});
event.preventDefault();
}
}

_onSlideEnd() {
Expand Down

0 comments on commit a87a000

Please sign in to comment.