rc-swipeout
Advanced tools
Comparing version 1.3.8 to 1.4.0
@@ -39,15 +39,4 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
value: function componentDidMount() { | ||
var _props = this.props, | ||
_props$left = _props.left, | ||
left = _props$left === undefined ? [] : _props$left, | ||
_props$right = _props.right, | ||
right = _props$right === undefined ? [] : _props$right; | ||
var width = this.content.offsetWidth; | ||
if (this.cover) { | ||
this.cover.style.width = width + 'px'; | ||
} | ||
this.contentWidth = width; | ||
this.btnsLeftWidth = width / 5 * left.length; | ||
this.btnsRightWidth = width / 5 * right.length; | ||
this.btnsLeftWidth = this.left ? this.left.offsetWidth : 0; | ||
this.btnsRightWidth = this.right ? this.right.offsetWidth : 0; | ||
document.body.addEventListener('touchstart', this.onCloseSwipe, true); | ||
@@ -94,7 +83,7 @@ } | ||
} | ||
var _props2 = this.props, | ||
_props2$left = _props2.left, | ||
left = _props2$left === undefined ? [] : _props2$left, | ||
_props2$right = _props2.right, | ||
right = _props2$right === undefined ? [] : _props2$right; | ||
var _props = this.props, | ||
_props$left = _props.left, | ||
left = _props$left === undefined ? [] : _props$left, | ||
_props$right = _props.right, | ||
right = _props$right === undefined ? [] : _props$right; | ||
@@ -114,15 +103,13 @@ var posX = e.deltaX - this.panStartX; | ||
} | ||
var _props3 = this.props, | ||
_props3$left = _props3.left, | ||
left = _props3$left === undefined ? [] : _props3$left, | ||
_props3$right = _props3.right, | ||
right = _props3$right === undefined ? [] : _props3$right; | ||
var _props2 = this.props, | ||
_props2$left = _props2.left, | ||
left = _props2$left === undefined ? [] : _props2$left, | ||
_props2$right = _props2.right, | ||
right = _props2$right === undefined ? [] : _props2$right; | ||
var posX = e.deltaX - this.panStartX; | ||
var contentWidth = this.contentWidth; | ||
var btnsLeftWidth = this.btnsLeftWidth; | ||
var btnsRightWidth = this.btnsRightWidth; | ||
var openX = contentWidth * 0.33; | ||
var openLeft = posX > openX || posX > btnsLeftWidth / 2; | ||
var openRight = posX < -openX || posX < -btnsRightWidth / 2; | ||
var openLeft = posX > btnsLeftWidth / 2; | ||
var openRight = posX < -btnsRightWidth / 2; | ||
if (openRight && posX < 0 && right.length) { | ||
@@ -165,7 +152,7 @@ this.open(-btnsRightWidth, false, true); | ||
value: function _setStyle(value) { | ||
var _props4 = this.props, | ||
_props4$left = _props4.left, | ||
left = _props4$left === undefined ? [] : _props4$left, | ||
_props4$right = _props4.right, | ||
right = _props4$right === undefined ? [] : _props4$right; | ||
var _props3 = this.props, | ||
_props3$left = _props3.left, | ||
left = _props3$left === undefined ? [] : _props3$left, | ||
_props3$right = _props3.right, | ||
right = _props3$right === undefined ? [] : _props3$right; | ||
@@ -179,10 +166,2 @@ var limit = value > 0 ? this.btnsLeftWidth : -this.btnsRightWidth; | ||
} | ||
if (left.length) { | ||
var leftWidth = Math.max(Math.min(value, Math.abs(limit)), 0); | ||
this.left.style.width = leftWidth + 'px'; | ||
} | ||
if (right.length) { | ||
var rightWidth = Math.max(Math.min(-value, Math.abs(limit)), 0); | ||
this.right.style.width = rightWidth + 'px'; | ||
} | ||
} | ||
@@ -189,0 +168,0 @@ }, { |
# History | ||
# 1.4.0 | ||
- improve: auto width for swipe buttons, #40 | ||
# 1.3.8 | ||
@@ -4,0 +8,0 @@ |
@@ -74,15 +74,4 @@ 'use strict'; | ||
value: function componentDidMount() { | ||
var _props = this.props, | ||
_props$left = _props.left, | ||
left = _props$left === undefined ? [] : _props$left, | ||
_props$right = _props.right, | ||
right = _props$right === undefined ? [] : _props$right; | ||
var width = this.content.offsetWidth; | ||
if (this.cover) { | ||
this.cover.style.width = width + 'px'; | ||
} | ||
this.contentWidth = width; | ||
this.btnsLeftWidth = width / 5 * left.length; | ||
this.btnsRightWidth = width / 5 * right.length; | ||
this.btnsLeftWidth = this.left ? this.left.offsetWidth : 0; | ||
this.btnsRightWidth = this.right ? this.right.offsetWidth : 0; | ||
document.body.addEventListener('touchstart', this.onCloseSwipe, true); | ||
@@ -129,7 +118,7 @@ } | ||
} | ||
var _props2 = this.props, | ||
_props2$left = _props2.left, | ||
left = _props2$left === undefined ? [] : _props2$left, | ||
_props2$right = _props2.right, | ||
right = _props2$right === undefined ? [] : _props2$right; | ||
var _props = this.props, | ||
_props$left = _props.left, | ||
left = _props$left === undefined ? [] : _props$left, | ||
_props$right = _props.right, | ||
right = _props$right === undefined ? [] : _props$right; | ||
@@ -149,15 +138,13 @@ var posX = e.deltaX - this.panStartX; | ||
} | ||
var _props3 = this.props, | ||
_props3$left = _props3.left, | ||
left = _props3$left === undefined ? [] : _props3$left, | ||
_props3$right = _props3.right, | ||
right = _props3$right === undefined ? [] : _props3$right; | ||
var _props2 = this.props, | ||
_props2$left = _props2.left, | ||
left = _props2$left === undefined ? [] : _props2$left, | ||
_props2$right = _props2.right, | ||
right = _props2$right === undefined ? [] : _props2$right; | ||
var posX = e.deltaX - this.panStartX; | ||
var contentWidth = this.contentWidth; | ||
var btnsLeftWidth = this.btnsLeftWidth; | ||
var btnsRightWidth = this.btnsRightWidth; | ||
var openX = contentWidth * 0.33; | ||
var openLeft = posX > openX || posX > btnsLeftWidth / 2; | ||
var openRight = posX < -openX || posX < -btnsRightWidth / 2; | ||
var openLeft = posX > btnsLeftWidth / 2; | ||
var openRight = posX < -btnsRightWidth / 2; | ||
if (openRight && posX < 0 && right.length) { | ||
@@ -200,7 +187,7 @@ this.open(-btnsRightWidth, false, true); | ||
value: function _setStyle(value) { | ||
var _props4 = this.props, | ||
_props4$left = _props4.left, | ||
left = _props4$left === undefined ? [] : _props4$left, | ||
_props4$right = _props4.right, | ||
right = _props4$right === undefined ? [] : _props4$right; | ||
var _props3 = this.props, | ||
_props3$left = _props3.left, | ||
left = _props3$left === undefined ? [] : _props3$left, | ||
_props3$right = _props3.right, | ||
right = _props3$right === undefined ? [] : _props3$right; | ||
@@ -214,10 +201,2 @@ var limit = value > 0 ? this.btnsLeftWidth : -this.btnsRightWidth; | ||
} | ||
if (left.length) { | ||
var leftWidth = Math.max(Math.min(value, Math.abs(limit)), 0); | ||
this.left.style.width = leftWidth + 'px'; | ||
} | ||
if (right.length) { | ||
var rightWidth = Math.max(Math.min(-value, Math.abs(limit)), 0); | ||
this.right.style.width = rightWidth + 'px'; | ||
} | ||
} | ||
@@ -224,0 +203,0 @@ }, { |
{ | ||
"name": "rc-swipeout", | ||
"version": "1.3.8", | ||
"version": "1.4.0", | ||
"description": "swipe out ui component for react(web and react-native)", | ||
@@ -60,3 +60,3 @@ "keywords": [ | ||
"pre-commit": "1.x", | ||
"rc-test": "6.0.3", | ||
"rc-test": "~6.0.3", | ||
"rc-tools": "6.x", | ||
@@ -63,0 +63,0 @@ "react": "^15.0.0", |
Sorry, the diff of this file is not supported yet
42012
963