rc-animate
Advanced tools
Comparing version 1.2.8 to 1.2.9
@@ -109,10 +109,16 @@ 'use strict'; | ||
var currentChildren = this.state.children; | ||
var newChildren = undefined; | ||
// in case destroy in showProp mode | ||
var newChildren = []; | ||
if (showProp) { | ||
newChildren = currentChildren.map(function (currentChild) { | ||
currentChildren.forEach(function (currentChild) { | ||
var nextChild = (0, _ChildrenUtils.findChildInChildrenByKey)(nextChildren, currentChild.key); | ||
if (!nextChild.props[showProp] && currentChild.props[showProp]) { | ||
return _react2['default'].cloneElement(nextChild, _defineProperty({}, showProp, true)); | ||
var newChild = undefined; | ||
if ((!nextChild || !nextChild.props[showProp]) && currentChild.props[showProp]) { | ||
newChild = _react2['default'].cloneElement(nextChild || currentChild, _defineProperty({}, showProp, true)); | ||
} else { | ||
newChild = nextChild; | ||
} | ||
return nextChild; | ||
if (newChild) { | ||
newChildren.push(newChild); | ||
} | ||
}); | ||
@@ -143,8 +149,10 @@ } else { | ||
if (showProp) { | ||
var showInNext = c.props[showProp]; | ||
if (hasPrev) { | ||
var showInNow = (0, _ChildrenUtils.findShownChildInChildrenByKey)(currentChildren, key, showProp); | ||
var showInNext = c.props[showProp]; | ||
if (!showInNow && showInNext) { | ||
_this2.keysToEnter.push(key); | ||
} | ||
} else if (showInNext) { | ||
_this2.keysToEnter.push(key); | ||
} | ||
@@ -163,8 +171,10 @@ } else if (!hasPrev) { | ||
if (showProp) { | ||
var showInNow = c.props[showProp]; | ||
if (hasNext) { | ||
var showInNext = (0, _ChildrenUtils.findShownChildInChildrenByKey)(nextChildren, key, showProp); | ||
var showInNow = c.props[showProp]; | ||
if (!showInNext && showInNow) { | ||
_this2.keysToLeave.push(key); | ||
} | ||
} else if (showInNow) { | ||
_this2.keysToLeave.push(key); | ||
} | ||
@@ -188,19 +198,23 @@ } else if (!hasNext) { | ||
var props = this.props; | ||
var children = this.state.children.map(function (child) { | ||
if (!child.key) { | ||
throw new Error('must set key for <rc-animate> children'); | ||
} | ||
return _react2['default'].createElement( | ||
_AnimateChild2['default'], | ||
{ | ||
key: child.key, | ||
ref: child.key, | ||
animation: props.animation, | ||
transitionName: props.transitionName, | ||
transitionEnter: props.transitionEnter, | ||
transitionAppear: props.transitionAppear, | ||
transitionLeave: props.transitionLeave }, | ||
child | ||
); | ||
}); | ||
var stateChildren = this.state.children; | ||
var children = null; | ||
if (stateChildren) { | ||
children = stateChildren.map(function (child) { | ||
if (!child.key) { | ||
throw new Error('must set key for <rc-animate> children'); | ||
} | ||
return _react2['default'].createElement( | ||
_AnimateChild2['default'], | ||
{ | ||
key: child.key, | ||
ref: child.key, | ||
animation: props.animation, | ||
transitionName: props.transitionName, | ||
transitionEnter: props.transitionEnter, | ||
transitionAppear: props.transitionAppear, | ||
transitionLeave: props.transitionLeave }, | ||
child | ||
); | ||
}); | ||
} | ||
var Component = props.component; | ||
@@ -207,0 +221,0 @@ if (Component) { |
@@ -23,3 +23,3 @@ 'use strict'; | ||
findChildInChildrenByKey: function findChildInChildrenByKey(children, key) { | ||
var ret = 0; | ||
var ret = null; | ||
if (children) { | ||
@@ -26,0 +26,0 @@ children.forEach(function (c) { |
{ | ||
"name": "rc-animate", | ||
"version": "1.2.8", | ||
"version": "1.2.9", | ||
"description": "css-transition ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
21869
468