rc-animate
Advanced tools
Comparing version 1.2.4 to 1.2.5
@@ -9,2 +9,4 @@ 'use strict'; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _react = require('react'); | ||
@@ -109,8 +111,17 @@ | ||
var newChildren = undefined; | ||
if (!showProp) { | ||
var needSetState = false; | ||
if (showProp) { | ||
needSetState = true; | ||
newChildren = currentChildren.map(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)); | ||
} | ||
return nextChild; | ||
}); | ||
} else { | ||
newChildren = _ChildrenUtils2['default'].mergeChildren(currentChildren, nextChildren); | ||
this.setState({ | ||
children: newChildren | ||
}); | ||
if (newChildren.length !== currentChildren.length || newChildren.length !== nextChildren.length) { | ||
needSetState = true; | ||
} | ||
} | ||
@@ -121,2 +132,3 @@ | ||
Object.keys(currentlyAnimatingKeys).forEach(function (key) { | ||
needSetState = false; | ||
_this2.stop(key); | ||
@@ -127,2 +139,8 @@ }); | ||
if (needSetState) { | ||
this.setState({ | ||
children: newChildren | ||
}); | ||
} | ||
nextChildren.forEach(function (c) { | ||
@@ -133,3 +151,3 @@ var key = c.key; | ||
} | ||
var hasPrev = (0, _ChildrenUtils.inChildren)(currentChildren, c); | ||
var hasPrev = (0, _ChildrenUtils.findChildInChildrenByKey)(currentChildren, key); | ||
if (showProp) { | ||
@@ -153,3 +171,3 @@ if (hasPrev) { | ||
} | ||
var hasNext = (0, _ChildrenUtils.inChildren)(nextChildren, c); | ||
var hasNext = (0, _ChildrenUtils.findChildInChildrenByKey)(nextChildren, key); | ||
if (showProp) { | ||
@@ -242,7 +260,2 @@ if (hasNext) { | ||
} | ||
if (this.isMounted() && !(0, _ChildrenUtils.isSameChildren)(this.state.children, currentChildren, props.showProp)) { | ||
this.setState({ | ||
children: currentChildren | ||
}); | ||
} | ||
} | ||
@@ -284,3 +297,3 @@ }, | ||
} | ||
return (0, _ChildrenUtils.inChildrenByKey)(currentChildren, key); | ||
return (0, _ChildrenUtils.findChildInChildrenByKey)(currentChildren, key); | ||
}, | ||
@@ -287,0 +300,0 @@ |
@@ -13,16 +13,3 @@ 'use strict'; | ||
function inChildren(children, child) { | ||
var found = 0; | ||
children.forEach(function (c) { | ||
if (found) { | ||
return; | ||
} | ||
found = c.key === child.key; | ||
}); | ||
return found; | ||
} | ||
exports['default'] = { | ||
inChildren: inChildren, | ||
var utils = { | ||
toArrayChildren: function toArrayChildren(children) { | ||
@@ -36,13 +23,15 @@ var ret = []; | ||
inChildrenByKey: function inChildrenByKey(children, key) { | ||
var found = 0; | ||
findChildInChildrenByKey: function findChildInChildrenByKey(children, key) { | ||
var ret = 0; | ||
if (children) { | ||
children.forEach(function (c) { | ||
if (found) { | ||
if (ret) { | ||
return; | ||
} | ||
found = c.key === key; | ||
if (c.key === key) { | ||
ret = c; | ||
} | ||
}); | ||
} | ||
return found; | ||
return ret; | ||
}, | ||
@@ -101,3 +90,3 @@ | ||
prev.forEach(function (c) { | ||
if (inChildren(next, c)) { | ||
if (utils.findChildInChildrenByKey(next, c.key)) { | ||
if (pendingChildren.length) { | ||
@@ -124,2 +113,4 @@ nextChildrenPending[c.key] = pendingChildren; | ||
}; | ||
exports['default'] = utils; | ||
module.exports = exports['default']; |
{ | ||
"name": "rc-animate", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "css-transition ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
21642
461