You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2021/07/06 12:21:15 UTC
[echarts] 01/02: fix(ut): more precise when determine if using id
as key
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch fix-universal-transition
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 9b904e659bfefa54467871004c1fdf12ba9bf63b
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Jul 6 20:18:16 2021 +0800
fix(ut): more precise when determine if using id as key
---
src/animation/universalTransition.ts | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/animation/universalTransition.ts b/src/animation/universalTransition.ts
index 53bf2da..140afca 100644
--- a/src/animation/universalTransition.ts
+++ b/src/animation/universalTransition.ts
@@ -142,6 +142,21 @@ function animateElementStyles(el: Element, dataIndex: number, seriesModel: Serie
}
+function isAllIdSame(oldDiffItems: DiffItem[], newDiffItems: DiffItem[]) {
+ const len = oldDiffItems.length;
+ if (len !== newDiffItems.length) {
+ return false;
+ }
+ for (let i = 0; i < len; i++) {
+ const oldItem = oldDiffItems[i];
+ const newItem = newDiffItems[i];
+ if (oldItem.data.getId(oldItem.dataIndex) !== newItem.data.getId(newItem.dataIndex)) {
+ return false;
+ }
+ }
+ return true;
+}
+
function transitionBetween(
oldList: TransitionSeries[],
newList: TransitionSeries[],
@@ -220,7 +235,7 @@ function transitionBetween(
// Use id if it's very likely to be an one to one animation
// It's more robust than groupId
// TODO Check if key dimension is specified.
- const useId = oldDiffItems.length === newDiffItems.length;
+ const useId = isAllIdSame(oldDiffItems, newDiffItems);
const isElementStillInChart: Dictionary<boolean> = {};
if (!useId) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org