Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(slider): work around slidestart event sometimes not firing on iOS #6009

Merged
merged 1 commit into from
Jul 27, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/lib/slider/slider.ts
Original file line number Diff line number Diff line change
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