rc-slider
Advanced tools
Comparing version 1.2.2 to 1.2.4
@@ -147,2 +147,7 @@ 'use strict'; | ||
_getTouchPosition: function _getTouchPosition(e) { | ||
var touch = e.touches[0]; | ||
return touch.pageX; | ||
}, | ||
_triggerEvents: function _triggerEvents(event) { | ||
@@ -156,13 +161,23 @@ var props = this.props; | ||
_addEventHandles: function _addEventHandles() { | ||
this._onMouseMoveListener = DomUtils.addEventListener(document, 'mousemove', this._onMouseMove); | ||
this._onMouseUpListener = DomUtils.addEventListener(document, 'mouseup', this._onMouseUp); | ||
_addEventHandles: function _addEventHandles(type) { | ||
if (type === 'touch') { | ||
// just work for chrome iOS Safari and Android Browser | ||
this._onTouchMoveListener = DomUtils.addEventListener(document, 'touchmove', this._onTouchMove); | ||
this._onTouchUpListener = DomUtils.addEventListener(document, 'touchend', this._onTouchUp); | ||
} | ||
if (type === 'mouse') { | ||
this._onMouseMoveListener = DomUtils.addEventListener(document, 'mousemove', this._onMouseMove); | ||
this._onMouseUpListener = DomUtils.addEventListener(document, 'mouseup', this._onMouseUp); | ||
} | ||
}, | ||
_removeEventHandles: function _removeEventHandles() { | ||
if (this._onMouseMoveListener) { | ||
this._onMouseMoveListener.remove(); | ||
_removeEventHandles: function _removeEventHandles(type) { | ||
if (type === 'touch') { | ||
this._onTouchMoveListener.remove(); | ||
this._onTouchUpListener.remove(); | ||
} | ||
if (this._onMouseUpListener) { | ||
if (type === 'mouse') { | ||
this._onMouseMoveListener.remove(); | ||
this._onMouseUpListener.remove(); | ||
@@ -185,4 +200,4 @@ } | ||
_end: function _end() { | ||
this._removeEventHandles(); | ||
_end: function _end(type) { | ||
this._removeEventHandles(type); | ||
this.setState(this._triggerEvents.bind(this, 'onAfterChange')); | ||
@@ -192,8 +207,27 @@ }, | ||
_onMouseUp: function _onMouseUp() { | ||
this._end(); | ||
this._end('mouse'); | ||
}, | ||
_onTouchUp: function _onTouchUp() { | ||
this._end('touch'); | ||
}, | ||
_onMouseMove: function _onMouseMove(e) { | ||
var position = this._getMousePosition(e); | ||
this._handleMove(e, position); | ||
}, | ||
_onTouchMove: function _onTouchMove(e) { | ||
if (e.touches.length > 1 || e.type === 'touchend' && e.touches.length > 0) { | ||
return; | ||
} | ||
var position = this._getTouchPosition(e); | ||
this._handleMove(e, position); | ||
}, | ||
_handleMove: function _handleMove(e, position) { | ||
pauseEvent(e); | ||
var position = this._getMousePosition(e); | ||
// var position = this._getMousePosition(e); | ||
var props = this.props; | ||
@@ -231,2 +265,14 @@ var state = this.state; | ||
handleTouchStart: function handleTouchStart(e) { | ||
if (this.props.disabled || e.touches.length > 1 || e.type === 'touchend' && e.touches.length > 0) { | ||
return; | ||
} | ||
var position = this._getTouchPosition(e); | ||
this.startPosition = position; | ||
this._start(position); | ||
this._addEventHandles('touch'); | ||
pauseEvent(e); | ||
}, | ||
handleMouseDown: function handleMouseDown() { | ||
@@ -241,3 +287,3 @@ var _this = this; | ||
_this._start(position); | ||
_this._addEventHandles(); | ||
_this._addEventHandles('mouse'); | ||
pauseEvent(e); | ||
@@ -257,3 +303,3 @@ }; | ||
_this2._start(position); | ||
_this2._addEventHandles(); | ||
_this2._addEventHandles('mouse'); | ||
}); | ||
@@ -357,3 +403,4 @@ pauseEvent(e); | ||
href: '#', | ||
onMouseDown: this.handleMouseDown }); | ||
onMouseDown: this.handleMouseDown, | ||
onTouchStart: this.handleTouchStart }); | ||
}, | ||
@@ -360,0 +407,0 @@ |
{ | ||
"name": "rc-slider", | ||
"version": "1.2.2", | ||
"version": "1.2.4", | ||
"description": "slider ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19547
468