rc-animate
Advanced tools
Comparing version 2.8.2 to 2.8.3
@@ -70,3 +70,32 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
/** | ||
* Merge same key when it remove and add again: | ||
* [1 - add, 2 - keep, 1 - remove] -> [1 - keep, 2 - keep] | ||
*/ | ||
var keys = {}; | ||
list.forEach(function (_ref) { | ||
var key = _ref.key; | ||
keys[key] = (keys[key] || 0) + 1; | ||
}); | ||
var duplicatedKeys = Object.keys(keys).filter(function (key) { | ||
return keys[key] > 1; | ||
}); | ||
duplicatedKeys.forEach(function (matchKey) { | ||
// Remove `STATUS_REMOVE` node. | ||
list = list.filter(function (_ref2) { | ||
var key = _ref2.key, | ||
status = _ref2.status; | ||
return key !== matchKey || status !== STATUS_REMOVE; | ||
}); | ||
// Update `STATUS_ADD` to `STATUS_KEEP` | ||
list.forEach(function (node) { | ||
if (node.key === matchKey) { | ||
node.status = STATUS_KEEP; | ||
} | ||
}); | ||
}); | ||
return list; | ||
} |
@@ -86,3 +86,32 @@ 'use strict'; | ||
/** | ||
* Merge same key when it remove and add again: | ||
* [1 - add, 2 - keep, 1 - remove] -> [1 - keep, 2 - keep] | ||
*/ | ||
var keys = {}; | ||
list.forEach(function (_ref) { | ||
var key = _ref.key; | ||
keys[key] = (keys[key] || 0) + 1; | ||
}); | ||
var duplicatedKeys = Object.keys(keys).filter(function (key) { | ||
return keys[key] > 1; | ||
}); | ||
duplicatedKeys.forEach(function (matchKey) { | ||
// Remove `STATUS_REMOVE` node. | ||
list = list.filter(function (_ref2) { | ||
var key = _ref2.key, | ||
status = _ref2.status; | ||
return key !== matchKey || status !== STATUS_REMOVE; | ||
}); | ||
// Update `STATUS_ADD` to `STATUS_KEEP` | ||
list.forEach(function (node) { | ||
if (node.key === matchKey) { | ||
node.status = STATUS_KEEP; | ||
} | ||
}); | ||
}); | ||
return list; | ||
} |
{ | ||
"name": "rc-animate", | ||
"version": "2.8.2", | ||
"version": "2.8.3", | ||
"description": "css-transition ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
90096
2221