Skip to content

Commit

Permalink
correct e.clientX
Browse files Browse the repository at this point in the history
  • Loading branch information
simaQ committed Apr 22, 2015
1 parent 13c4e13 commit b61f0bb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/Slider.js
Expand Up @@ -137,6 +137,10 @@ var Slider = React.createClass({
this.setState({value: nextValue, active: 'active'}, callback);
},

_getMousePosition: function(e) {
return e.pageX || (e.clientX + document.documentElement.scrollLeft);
},

_triggerEvents: function(event) {
var props = this.props;
var hasMarks = props.marks && props.marks.length > 0;
Expand Down Expand Up @@ -184,7 +188,7 @@ var Slider = React.createClass({

_onMouseMove: function(e) {
pauseEvent(e);
var position = e.pageX || e.clientX;
var position = this._getMousePosition(e);
var props = this.props;
var state = this.state;

Expand Down Expand Up @@ -222,7 +226,7 @@ var Slider = React.createClass({
if (this.props.disabled) {
return;
}
var position = e.pageX || e.clientX;
var position = this._getMousePosition(e);
this._start(position);
this._addEventHandles();
pauseEvent(e);
Expand All @@ -233,7 +237,7 @@ var Slider = React.createClass({
if (this.props.disabled) {
return;
}
var position = e.pageX || e.clientX;
var position = this._getMousePosition(e);
this._calValueByPos(position,
() => {
this._triggerEvents('onChange');
Expand Down

0 comments on commit b61f0bb

Please sign in to comment.