Skip to content

Commit

Permalink
fix paper-slider on ios. closes #645 (for real).
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelcobain committed Feb 23, 2017
1 parent 41fe454 commit a86bb64
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions addon/components/paper-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,23 @@ export default Component.extend(FocusableMixin, ColorMixin, {
event.preventDefault();
},

// needed for iOS
// iOS doesn't trigger a click event on normal divs
// unless we use `cursor: pointer` css
touchEnd(e) {
this.click(e);
},

click(event) {
if (this.get('disabled')) {
return;
}

this.setValueFromEvent(event);
this.setValueFromEvent(event.pageX || event.clientX);
},

setValueFromEvent(event) {
let exactVal = this.percentToValue(this.positionToPercent(event.clientX || event.srcEvent.clientX));
setValueFromEvent(value) {
let exactVal = this.percentToValue(this.positionToPercent(value));
let closestVal = this.minMaxValidator(this.stepValidator(exactVal));

this.sendAction('onChange', closestVal);
Expand All @@ -156,18 +163,18 @@ export default Component.extend(FocusableMixin, ColorMixin, {
this.set('dragging', true);
this.$().focus();

this.setValueFromEvent(event);
this.setValueFromEvent(event.center.x);
},

drag(event) {
if (this.get('disabled') || !this.get('dragging')) {
return;
}

this.setValueFromEvent(event);
this.setValueFromEvent(event.center.x);
},

dragEnd() {
dragEnd(event) {
if (this.get('disabled')) {
return;
}
Expand Down

0 comments on commit a86bb64

Please sign in to comment.