rc-swipeout
Advanced tools
Comparing version 1.2.2 to 1.2.3
# History | ||
## 1.2.3 | ||
- add cover `div`, for body touchstart | ||
- fix: buttons cannot be hidden when pan short distance | ||
## 1.2.2 | ||
@@ -4,0 +9,0 @@ |
@@ -63,4 +63,2 @@ 'use strict'; | ||
Swipeout.prototype.componentDidMount = function componentDidMount() { | ||
var _this2 = this; | ||
var _props = this.props; | ||
@@ -72,2 +70,6 @@ var left = _props.left; | ||
if (this.refs.cover) { | ||
this.refs.cover.style.width = width + 'px'; | ||
} | ||
this.contentWidth = width; | ||
@@ -77,24 +79,26 @@ this.btnsLeftWidth = width / 5 * left.length; | ||
document.body.addEventListener('touchstart', function (ev) { | ||
if (_this2.openedLeft || _this2.openedRight) { | ||
var pNode = function (node) { | ||
while (node.parentNode && node.parentNode !== document.body) { | ||
if (node.className.indexOf('rc-swipeout-actions') > -1) { | ||
return node; | ||
} | ||
node = node.parentNode; | ||
document.body.addEventListener('touchstart', this.onCloseSwipe.bind(this), true); | ||
}; | ||
Swipeout.prototype.componentWillUnmount = function componentWillUnmount() { | ||
document.body.removeEventListener('touchstart', this.onCloseSwipe.bind(this)); | ||
}; | ||
Swipeout.prototype.onCloseSwipe = function onCloseSwipe(ev) { | ||
if (this.openedLeft || this.openedRight) { | ||
var pNode = function (node) { | ||
while (node.parentNode && node.parentNode !== document.body) { | ||
if (node.className.indexOf('rc-swipeout-actions') > -1) { | ||
return node; | ||
} | ||
}(ev.target); | ||
if (!pNode) { | ||
ev.preventDefault(); | ||
_this2.close(); | ||
node = node.parentNode; | ||
} | ||
}(ev.target); | ||
if (!pNode) { | ||
ev.preventDefault(); | ||
this.close(); | ||
} | ||
}, true); | ||
} | ||
}; | ||
Swipeout.prototype.componentWillUnmount = function componentWillUnmount() { | ||
document.body.removeEventListener('click'); | ||
}; | ||
Swipeout.prototype.onPanStart = function onPanStart(e) { | ||
@@ -114,11 +118,4 @@ if (this.props.disabled) { | ||
var right = _props2.right; | ||
// get pan distance | ||
var posX = e.deltaX - this.panStartX; | ||
if (this.openedRight) { | ||
posX = posX - this.btnsRightWidth; | ||
} else if (this.openedLeft) { | ||
posX = posX + this.btnsLeftWidth; | ||
} | ||
if (posX < 0 && right.length) { | ||
@@ -135,2 +132,3 @@ this._setStyle(Math.min(posX, 0)); | ||
} | ||
var _props3 = this.props; | ||
@@ -148,9 +146,2 @@ var left = _props3.left; | ||
if (this.openedRight) { | ||
openRight = posX - openX < -openX; | ||
} | ||
if (this.openedLeft) { | ||
openLeft = posX + openX > openX; | ||
} | ||
if (openRight && posX < 0 && right.length) { | ||
@@ -199,2 +190,4 @@ this.open(-btnsRightWidth, false, true); | ||
this.refs.content.style.left = contentLeft + 'px'; | ||
this.refs.cover.style.display = Math.abs(value) > 0 ? 'block' : 'none'; | ||
this.refs.cover.style.left = contentLeft + 'px'; | ||
if (left.length) { | ||
@@ -223,4 +216,4 @@ var leftWidth = Math.max(Math.min(value, Math.abs(limit)), 0); | ||
this.props.onClose(); | ||
this._setStyle(0); | ||
} | ||
this._setStyle(0); | ||
this.openedLeft = false; | ||
@@ -231,3 +224,3 @@ this.openedRight = false; | ||
Swipeout.prototype.renderButtons = function renderButtons(buttons, ref) { | ||
var _this3 = this; | ||
var _this2 = this; | ||
@@ -246,3 +239,3 @@ var prefixCls = this.props.prefixCls; | ||
onClick: function onClick(e) { | ||
return _this3.onBtnClick(e, btn); | ||
return _this2.onBtnClick(e, btn); | ||
} | ||
@@ -291,2 +284,3 @@ }, | ||
), | ||
_react2["default"].createElement('div', { className: prefixCls + '-cover', ref: 'cover' }), | ||
this.renderButtons(left, 'left'), | ||
@@ -293,0 +287,0 @@ this.renderButtons(right, 'right') |
{ | ||
"name": "rc-swipeout", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "swipe out ui component for react(web and react-native)", | ||
@@ -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
20917
467