This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch enhance-morph
in repository https://gitbox.apache.org/repos/asf/echarts.git


The following commit(s) were added to refs/heads/enhance-morph by this push:
     new d49b9f6  feat(ut): optimize transition between line and others
d49b9f6 is described below

commit d49b9f6558b766dadf4547b5bd947c8277a6cd82
Author: pissang <[email protected]>
AuthorDate: Tue Jun 15 23:29:19 2021 +0800

    feat(ut): optimize transition between line and others
    
    stop animation of all elements in the group
---
 src/animation/universalTransition.ts | 62 ++++++++++++++++++++++++------------
 src/chart/line/LineView.ts           |  1 +
 2 files changed, 42 insertions(+), 21 deletions(-)

diff --git a/src/animation/universalTransition.ts 
b/src/animation/universalTransition.ts
index 686569a..b5558f8 100644
--- a/src/animation/universalTransition.ts
+++ b/src/animation/universalTransition.ts
@@ -43,23 +43,31 @@ function transitionBetweenData(
     // const oldSeriesModel = oldData.hostModel;
     // const isTransitionSameSeries = oldSeriesModel === seriesModel;
 
-
-    function stopAnimation(pathList: Path[] | Path[][]) {
-        if (isArray(pathList[0])) {
-            for (let i = 0; i < pathList.length; i++) {
-                stopAnimation(pathList[i] as Path[]);
-            }
-        }
-        else {
-            // TODO Group itself should also invoke the callback.
-            // Force finish the leave animation.
-            for (let i = 0; i < pathList.length; i++) {
-                (pathList as Path[])[i].stopAnimation();
-            }
+    function stopAnimation(el: Element) {
+        el.stopAnimation();
+        if (el.isGroup) {
+            el.traverse(child => {
+                child.stopAnimation();
+            });
         }
-        return pathList;
     }
 
+    // function stopAnimation(pathList: Path[] | Path[][]) {
+    //     if (isArray(pathList[0])) {
+    //         for (let i = 0; i < pathList.length; i++) {
+    //             stopAnimation(pathList[i] as Path[]);
+    //         }
+    //     }
+    //     else {
+    //         // TODO Group itself should also invoke the callback.
+    //         // Force finish the leave animation.
+    //         for (let i = 0; i < pathList.length; i++) {
+    //             (pathList as Path[])[i].stopAnimation();
+    //         }
+    //     }
+    //     return pathList;
+    // }
+
     function updateMorphingPathProps(
         from: Path, to: Path,
         rawFrom: Path, rawTo: Path,
@@ -136,13 +144,19 @@ function transitionBetweenData(
         }
 
         if (newEl) {
+            // TODO: If keep animating the group in case
+            // some of the elements don't want to be morphed.
+            stopAnimation(newEl);
+
             if (oldEl) {
+                stopAnimation(oldEl);
+
                 // If old element is doing leaving animation. stop it and 
remove it immediately.
                 removeEl(oldEl);
 
                 applyMorphAnimation(
-                    stopAnimation(getPathList(oldEl)),
-                    stopAnimation(getPathList(newEl)),
+                    getPathList(oldEl),
+                    getPathList(newEl),
                     seriesModel,
                     newIndex,
                     updateMorphingPathProps
@@ -172,13 +186,17 @@ function transitionBetweenData(
         );
 
         if (newEl) {
+            stopAnimation(newEl);
             if (oldElsList.length) {
                 // If old element is doing leaving animation. stop it and 
remove it immediately.
-                each(oldElsList, oldEl => removeEl(oldEl));
+                each(oldElsList, oldEl => {
+                    stopAnimation(oldEl);
+                    removeEl(oldEl);
+                });
 
                 applyMorphAnimation(
-                    stopAnimation(getPathList(oldElsList)),
-                    stopAnimation(getPathList(newEl)),
+                    getPathList(oldElsList),
+                    getPathList(newEl),
                     seriesModel,
                     newIndex,
                     updateMorphingPathProps
@@ -198,13 +216,15 @@ function transitionBetweenData(
         );
 
         if (newElsList.length) {
+            each(newElsList, newEl => stopAnimation(newEl));
             if (oldEl) {
+                stopAnimation(oldEl);
                 // If old element is doing leaving animation. stop it and 
remove it immediately.
                 removeEl(oldEl);
 
                 applyMorphAnimation(
-                    stopAnimation(getPathList(oldEl)),
-                    stopAnimation(getPathList(newElsList)),
+                    getPathList(oldEl),
+                    getPathList(newElsList),
                     seriesModel,
                     newIndices[0],
                     updateMorphingPathProps
diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts
index 282ad3f..ccf15fd 100644
--- a/src/chart/line/LineView.ts
+++ b/src/chart/line/LineView.ts
@@ -1042,6 +1042,7 @@ class LineView extends ChartView {
                     scaleY: 1
                 }, {
                     duration: 200,
+                    setToFinal: true,
                     delay: delay
                 });
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to