Merge pull request #9 from benjycui/fix-bug

修复动画导致 Slider 滑块偏移的 Bug。
This commit is contained in:
Emma
2015-07-13 14:21:46 +08:00
+9 -3
View File
@@ -130,7 +130,7 @@ var Slider = React.createClass({
},
_calValueByPos: function (position, callback) {
var pixelOffset = position - this.state.sliderStart;
var pixelOffset = position - this.getSliderStart();
// pixelOffset -= (this.state.handleSize / 2);
var nextValue = this._trimAlignValue(this._calcValue(pixelOffset));
@@ -251,11 +251,17 @@ var Slider = React.createClass({
this.setState({
upperBound: slider.clientWidth,
sliderLength: Math.abs(sliderMax - sliderMin),
sliderStart: sliderMin
sliderLength: Math.abs(sliderMax - sliderMin)
});
},
getSliderStart: function() {
var slider = this.refs.slider.getDOMNode();
var rect = slider.getBoundingClientRect();
return rect.left;
},
handleTouchStart: function(e) {
if (this.props.disabled || e.touches.length > 1 || (e.type === 'touchend' && e.touches.length > 0)) {
return;