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/11/24 09:17:12 UTC

[echarts] branch refact-series-animation created (now 6f0179d)

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

shenyi pushed a change to branch refact-series-animation
in repository https://gitbox.apache.org/repos/asf/echarts.git.


      at 6f0179d  refact(animation): introduce enter, update, leave animation

This branch includes the following new commits:

     new 6f0179d  refact(animation): introduce enter, update, leave animation

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[echarts] 01/01: refact(animation): introduce enter, update, leave animation

Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6f0179df8870c9ba3a358d133505071ce3520d0d
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Nov 24 17:16:32 2021 +0800

    refact(animation): introduce enter, update, leave animation
    
    enterAnimation to replace the original animationDuration, animationEasing, animationDelay.
    updateAnimation to replace the original animationDurationUpdate, animationEasingUpdate, animationDelayUpdate.
    new leaveAnimation
---
 src/animation/basicTrasition.ts                 | 54 +++++++------------------
 src/animation/customGraphicKeyframeAnimation.ts |  6 +++
 src/animation/customGraphicTransition.ts        |  3 +-
 src/chart/bar/BarView.ts                        |  2 +-
 src/chart/bar/PictorialBarView.ts               |  2 +-
 src/chart/boxplot/BoxplotSeries.ts              |  4 +-
 src/chart/candlestick/CandlestickSeries.ts      |  6 ++-
 src/chart/helper/Symbol.ts                      | 11 ++---
 src/chart/line/LineView.ts                      | 10 ++---
 src/chart/pie/PieSeries.ts                      |  9 +----
 src/chart/pie/labelLayout.ts                    | 12 ++++--
 src/chart/sankey/SankeySeries.ts                |  6 +--
 src/chart/sunburst/SunburstSeries.ts            |  2 -
 src/chart/tree/TreeSeries.ts                    | 16 ++++++--
 src/chart/tree/TreeView.ts                      | 25 ++++--------
 src/chart/treemap/TreemapSeries.ts              |  8 ++--
 src/chart/treemap/TreemapView.ts                |  4 +-
 src/component/axisPointer/AxisPointerModel.ts   |  5 ++-
 src/component/axisPointer/BaseAxisPointer.ts    |  2 +-
 src/component/axisPointer/modelHelper.ts        |  2 +-
 src/component/dataZoom/DataZoomModel.ts         |  7 +---
 src/component/legend/ScrollableLegendModel.ts   | 10 ++++-
 src/component/timeline/SliderTimelineModel.ts   |  8 ++--
 src/component/timeline/SliderTimelineView.ts    |  4 +-
 src/component/timeline/TimelineModel.ts         | 12 +++++-
 src/component/tooltip/TooltipModel.ts           |  7 +++-
 src/model/globalDefault.ts                      | 20 ++++++---
 src/preprocessor/backwardCompat.ts              | 49 +++++++++++++++++++++-
 src/util/types.ts                               | 39 +++++++++++-------
 29 files changed, 205 insertions(+), 140 deletions(-)

diff --git a/src/animation/basicTrasition.ts b/src/animation/basicTrasition.ts
index bc31f39..c94a00f 100644
--- a/src/animation/basicTrasition.ts
+++ b/src/animation/basicTrasition.ts
@@ -22,16 +22,12 @@
 import {
     AnimationOptionMixin,
     AnimationDelayCallbackParam,
-    PayloadAnimationPart,
-    AnimationOption
+    PayloadAnimationPart
 } from '../util/types';
 import { AnimationEasing } from 'zrender/src/animation/easing';
 import Element, { ElementAnimateConfig } from 'zrender/src/Element';
 import Model from '../model/Model';
-import {
-    isObject,
-    retrieve2
-} from 'zrender/src/core/util';
+import { isObject } from 'zrender/src/core/util';
 import Displayable from 'zrender/src/graphic/Displayable';
 import Group from 'zrender/src/graphic/Group';
 import { makeInner } from '../util/model';
@@ -47,7 +43,6 @@ type AnimateOrSetPropsOption = {
     dataIndex?: number;
     cb?: () => void;
     during?: (percent: number) => void;
-    removeOpt?: AnimationOption
     isFrom?: boolean;
 };
 
@@ -55,11 +50,9 @@ type AnimateOrSetPropsOption = {
  * Return null if animation is disabled.
  */
 export function getAnimationConfig(
-    animationType: 'init' | 'update' | 'remove',
+    animationType: 'enter' | 'update' | 'leave',
     animatableModel: Model<AnimationOptionMixin>,
     dataIndex: number,
-    // Extra opts can override the option in animatable model.
-    extraOpts?: Pick<ElementAnimateConfig, 'easing' | 'duration' | 'delay'>,
     // TODO It's only for pictorial bar now.
     extraDelayParams?: unknown
 ): Pick<ElementAnimateConfig, 'easing' | 'duration' | 'delay'> | null {
@@ -73,28 +66,12 @@ export function getAnimationConfig(
     }
     const animationEnabled = animatableModel && animatableModel.isAnimationEnabled();
 
-    const isUpdate = animationType === 'update';
-
     if (animationEnabled) {
-        let duration: number | Function;
-        let easing: AnimationEasing;
-        let delay: number | Function;
-        if (extraOpts) {
-            duration = retrieve2(extraOpts.duration, 200);
-            easing = retrieve2(extraOpts.easing, 'cubicOut');
-            delay = 0;
-        }
-        else {
-            duration = animatableModel.getShallow(
-                isUpdate ? 'animationDurationUpdate' : 'animationDuration'
-            );
-            easing = animatableModel.getShallow(
-                isUpdate ? 'animationEasingUpdate' : 'animationEasing'
-            );
-            delay = animatableModel.getShallow(
-                isUpdate ? 'animationDelayUpdate' : 'animationDelay'
-            );
-        }
+        const animationProp = `${animationType}Animation` as const;
+        const model = animatableModel.getModel(animationProp);
+        let duration: number | Function = model.getShallow('duration');
+        let easing: AnimationEasing = model.getShallow('easing');
+        let delay: number | Function = model.getShallow('delay');
         // animation from payload has highest priority.
         if (animationPayload) {
             animationPayload.duration != null && (duration = animationPayload.duration);
@@ -124,7 +101,7 @@ export function getAnimationConfig(
 }
 
 function animateOrSetProps<Props>(
-    animationType: 'init' | 'update' | 'remove',
+    animationType: 'enter' | 'update' | 'leave',
     el: Element<Props>,
     props: Props,
     animatableModel?: Model<AnimationOptionMixin> & {
@@ -135,7 +112,6 @@ function animateOrSetProps<Props>(
     during?: AnimateOrSetPropsOption['during']
 ) {
     let isFrom = false;
-    let removeOpt: AnimationOption;
     if (typeof dataIndex === 'function') {
         during = cb;
         cb = dataIndex;
@@ -145,22 +121,20 @@ function animateOrSetProps<Props>(
         cb = dataIndex.cb;
         during = dataIndex.during;
         isFrom = dataIndex.isFrom;
-        removeOpt = dataIndex.removeOpt;
         dataIndex = dataIndex.dataIndex;
     }
 
-    const isRemove = (animationType === 'remove');
+    const isRemove = (animationType === 'leave');
 
     if (!isRemove) {
         // Must stop the remove animation.
-        el.stopAnimation('remove');
+        el.stopAnimation('leave');
     }
 
     const animationConfig = getAnimationConfig(
         animationType,
         animatableModel,
         dataIndex as number,
-        isRemove ? (removeOpt || {}) : null,
         (animatableModel && animatableModel.getAnimationDelayParams)
             ? animatableModel.getAnimationDelayParams(el, dataIndex as number)
             : null
@@ -245,7 +219,7 @@ export function initProps<Props>(
     cb?: AnimateOrSetPropsOption['cb'] | AnimateOrSetPropsOption['during'],
     during?: AnimateOrSetPropsOption['during']
 ) {
-    animateOrSetProps('init', el, props, animatableModel, dataIndex, cb, during);
+    animateOrSetProps('enter', el, props, animatableModel, dataIndex, cb, during);
 }
 
 /**
@@ -258,7 +232,7 @@ export function initProps<Props>(
     }
     for (let i = 0; i < el.animators.length; i++) {
         const animator = el.animators[i];
-        if (animator.scope === 'remove') {
+        if (animator.scope === 'leave') {
             return true;
         }
     }
@@ -281,7 +255,7 @@ export function removeElement<Props>(
         return;
     }
 
-    animateOrSetProps('remove', el, props, animatableModel, dataIndex, cb, during);
+    animateOrSetProps('leave', el, props, animatableModel, dataIndex, cb, during);
 }
 
 function fadeOutDisplayable(
diff --git a/src/animation/customGraphicKeyframeAnimation.ts b/src/animation/customGraphicKeyframeAnimation.ts
index addbf79..ecd7861 100644
--- a/src/animation/customGraphicKeyframeAnimation.ts
+++ b/src/animation/customGraphicKeyframeAnimation.ts
@@ -23,6 +23,8 @@ import { keys, filter, each } from 'zrender/src/core/util';
 import { ELEMENT_ANIMATABLE_PROPS } from './customGraphicTransition';
 import { AnimationOption } from '../util/types';
 
+const KEYFRAME_ANIMATOR_SCOPE = 'keyframe';
+
 // Helpers for creating keyframe based animations in custom series and graphic components.
 
 type AnimationKeyframe<T extends Record<string, any>> = T & {
@@ -45,12 +47,16 @@ export function applyKeyframeAnimation<T extends Record<string, any>>(
         return;
     }
 
+    // Stop all keyframe animations applied before.
+    el.stopAnimation(KEYFRAME_ANIMATOR_SCOPE);
+
     function applyKeyframeAnimationOnProp(propName: typeof ELEMENT_ANIMATABLE_PROPS[number]) {
         if (propName && !(el as any)[propName]) {
             return;
         }
 
         const animator = el.animate(propName, animationOpts.loop);
+        animator.scope = KEYFRAME_ANIMATOR_SCOPE;
         each(keyframes, kf => {
             // Stop current animation.
             const animators = el.animators;
diff --git a/src/animation/customGraphicTransition.ts b/src/animation/customGraphicTransition.ts
index 67b25ce..11be870 100644
--- a/src/animation/customGraphicTransition.ts
+++ b/src/animation/customGraphicTransition.ts
@@ -28,7 +28,7 @@ import Model from '../model/Model';
 import { initProps, updateProps } from './basicTrasition';
 import { Path } from '../util/graphic';
 import { warn } from '../util/log';
-import { AnimationOptionMixin, ZRStyleProps } from '../util/types';
+import { ZRStyleProps, AnimationOptionMixin } from '../util/types';
 import { Dictionary } from 'zrender/src/core/types';
 import { PathStyleProps } from 'zrender';
 
@@ -222,7 +222,6 @@ function applyPropsDirectly(
     if (!el.isGroup && styleOpt) {
         if (clearStyle) {
             (el as Displayable).useStyle({});
-
             // When style object changed, how to trade the existing animation?
             // It is probably complicated and not needed to cover all the cases.
             // But still need consider the case:
diff --git a/src/chart/bar/BarView.ts b/src/chart/bar/BarView.ts
index c87e327..cb72cfb 100644
--- a/src/chart/bar/BarView.ts
+++ b/src/chart/bar/BarView.ts
@@ -386,7 +386,7 @@ class BarView extends ChartView {
                             /**
                              * Set preValue to be value so that no new label
                              * should be started, otherwise, it will take a full
-                             * `animationDurationUpdate` time to finish the
+                             * `updateAnimation.duration` time to finish the
                              * animation, which is not expected.
                              */
                             labelInnerStore.prevValue = labelInnerStore.value;
diff --git a/src/chart/bar/PictorialBarView.ts b/src/chart/bar/PictorialBarView.ts
index 1a81fed..54ca9e7 100644
--- a/src/chart/bar/PictorialBarView.ts
+++ b/src/chart/bar/PictorialBarView.ts
@@ -30,7 +30,7 @@ import ExtensionAPI from '../../core/ExtensionAPI';
 import SeriesData from '../../data/SeriesData';
 import GlobalModel from '../../model/Global';
 import Model from '../../model/Model';
-import { ColorString, AnimationOptionMixin, ECElement } from '../../util/types';
+import { ColorString, ECElement, AnimationOptionMixin } from '../../util/types';
 import type Cartesian2D from '../../coord/cartesian/Cartesian2D';
 import type Displayable from 'zrender/src/graphic/Displayable';
 import type Axis2D from '../../coord/cartesian/Axis2D';
diff --git a/src/chart/boxplot/BoxplotSeries.ts b/src/chart/boxplot/BoxplotSeries.ts
index 69c7c1c..774c899 100644
--- a/src/chart/boxplot/BoxplotSeries.ts
+++ b/src/chart/boxplot/BoxplotSeries.ts
@@ -127,7 +127,9 @@ class BoxplotSeriesModel extends SeriesModel<BoxplotSeriesOption> {
             }
         },
 
-        animationDuration: 800
+        enterAnimation: {
+            duration: 800
+        }
     };
 }
 
diff --git a/src/chart/candlestick/CandlestickSeries.ts b/src/chart/candlestick/CandlestickSeries.ts
index 6f104e5..5d8bf41 100644
--- a/src/chart/candlestick/CandlestickSeries.ts
+++ b/src/chart/candlestick/CandlestickSeries.ts
@@ -139,8 +139,10 @@ class CandlestickSeriesModel extends SeriesModel<CandlestickSeriesOption> {
         progressiveThreshold: 1e4,
         progressiveChunkMode: 'mod',
 
-        animationEasing: 'linear',
-        animationDuration: 300
+        enterAnimation: {
+            easing: 'linear',
+            duration: 300
+        }
     };
 
     /**
diff --git a/src/chart/helper/Symbol.ts b/src/chart/helper/Symbol.ts
index be2a5a4..e4e59b9 100644
--- a/src/chart/helper/Symbol.ts
+++ b/src/chart/helper/Symbol.ts
@@ -198,8 +198,8 @@ class Symbol extends graphic.Group {
         }
 
         if (disableAnimation) {
-            // Must stop remove animation manually if don't call initProps or updateProps.
-            this.childAt(0).stopAnimation('remove');
+            // Must stop leave animation manually if don't call initProps or updateProps.
+            this.childAt(0).stopAnimation('leave');
         }
 
         this._seriesModel = seriesModel;
@@ -351,13 +351,11 @@ class Symbol extends graphic.Group {
     }
 
     fadeOut(cb: () => void, opt?: {
-        fadeLabel: boolean,
-        animation?: AnimationOption
+        fadeLabel: boolean
     }) {
         const symbolPath = this.childAt(0) as ECSymbol;
         const seriesModel = this._seriesModel;
         const dataIndex = getECData(this).dataIndex;
-        const animationOpt = opt && opt.animation;
         // Avoid mistaken hover when fading out
         this.silent = symbolPath.silent = true;
         // Not show text when animating
@@ -370,7 +368,6 @@ class Symbol extends graphic.Group {
                     }
                 }, seriesModel, {
                     dataIndex,
-                    removeOpt: animationOpt,
                     cb() {
                         symbolPath.removeTextContent();
                     }
@@ -391,7 +388,7 @@ class Symbol extends graphic.Group {
                 scaleY: 0
             },
             seriesModel,
-            { dataIndex, cb, removeOpt: animationOpt}
+            { dataIndex, cb}
         );
     }
 
diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts
index 97059f6..9fdce44 100644
--- a/src/chart/line/LineView.ts
+++ b/src/chart/line/LineView.ts
@@ -1063,12 +1063,12 @@ class LineView extends ChartView {
         }
 
         const seriesModel = data.hostModel;
-        let seriesDuration = seriesModel.get('animationDuration');
-        if (typeof seriesDuration === 'function') {
+        let seriesDuration = seriesModel.get(['enterAnimation', 'duration']);
+        if (zrUtil.isFunction(seriesDuration)) {
             seriesDuration = seriesDuration(null);
         }
-        const seriesDalay = seriesModel.get('animationDelay') || 0;
-        const seriesDalayValue = typeof seriesDalay === 'function'
+        const seriesDalay = seriesModel.get(['enterAnimation', 'delay']) || 0;
+        const seriesDalayValue = zrUtil.isFunction(seriesDalay)
             ? seriesDalay(null)
             : seriesDalay;
 
@@ -1113,7 +1113,7 @@ class LineView extends ChartView {
                     ratio = 1 - ratio;
                 }
 
-                const delay = typeof seriesDalay === 'function' ? seriesDalay(idx)
+                const delay = zrUtil.isFunction(seriesDalay) ? seriesDalay(idx)
                     : (seriesDuration * ratio) + seriesDalayValue;
 
                 const symbolPath = el.getSymbolPath();
diff --git a/src/chart/pie/PieSeries.ts b/src/chart/pie/PieSeries.ts
index f306faf..c6af96f 100644
--- a/src/chart/pie/PieSeries.ts
+++ b/src/chart/pie/PieSeries.ts
@@ -304,15 +304,8 @@ class PieSeriesModel extends SeriesModel<PieSeriesOption> {
 
         // Animation type. Valid values: expansion, scale
         animationType: 'expansion',
-
-        animationDuration: 1000,
-
         // Animation type when update. Valid values: transition, expansion
-        animationTypeUpdate: 'transition',
-
-        animationEasingUpdate: 'cubicInOut',
-        animationDurationUpdate: 500,
-        animationEasing: 'cubicInOut'
+        animationTypeUpdate: 'transition'
     };
 
 }
diff --git a/src/chart/pie/labelLayout.ts b/src/chart/pie/labelLayout.ts
index 14be831..a8adcd8 100644
--- a/src/chart/pie/labelLayout.ts
+++ b/src/chart/pie/labelLayout.ts
@@ -195,10 +195,16 @@ function avoidOverlap(
                 }
             }
             if (targetTextWidth < layout.rect.width) {
-                // TODOTODO
-                // layout.text = textContain.truncateText(layout.text, targetTextWidth, layout.font);
-                layout.label.style.width = targetTextWidth;
+                layout.label.setStyle('width', targetTextWidth);
                 if (layout.labelAlignTo === 'edge') {
+                    const oldBackgroundColor = layout.label.style.backgroundColor;
+                    layout.label.style.backgroundColor = null;
+                    const width = layout.label.getBoundingRect().width;
+                    if (width < layout.rect.width) {
+                        layout.label.setStyle('width', width);
+                    }
+                    layout.label.style.backgroundColor = oldBackgroundColor;
+                    targetTextWidth = width;
                     realTextWidth = targetTextWidth;
                     // realTextWidth = textContain.getWidth(layout.text, layout.font);
                 }
diff --git a/src/chart/sankey/SankeySeries.ts b/src/chart/sankey/SankeySeries.ts
index 2ef1e77..92ee88a 100644
--- a/src/chart/sankey/SankeySeries.ts
+++ b/src/chart/sankey/SankeySeries.ts
@@ -323,9 +323,9 @@ class SankeySeriesModel extends SeriesModel<SankeySeriesOption> {
             }
         },
 
-        animationEasing: 'linear',
-
-        animationDuration: 1000
+        enterAnimation: {
+            easing: 'linear'
+        }
     };
 }
 
diff --git a/src/chart/sunburst/SunburstSeries.ts b/src/chart/sunburst/SunburstSeries.ts
index e145747..cae529a 100644
--- a/src/chart/sunburst/SunburstSeries.ts
+++ b/src/chart/sunburst/SunburstSeries.ts
@@ -271,8 +271,6 @@ class SunburstSeriesModel extends SeriesModel<SunburstSeriesOption> {
 
         // Animation type canbe expansion, scale
         animationType: 'expansion',
-        animationDuration: 1000,
-        animationDurationUpdate: 500,
 
         data: [],
 
diff --git a/src/chart/tree/TreeSeries.ts b/src/chart/tree/TreeSeries.ts
index 53768bd..b13cab0 100644
--- a/src/chart/tree/TreeSeries.ts
+++ b/src/chart/tree/TreeSeries.ts
@@ -300,11 +300,21 @@ class TreeSeriesModel extends SeriesModel<TreeSeriesOption> {
             show: true
         },
 
-        animationEasing: 'linear',
+        enterAnimation: {
+            duration: 700,
+            easing: 'linear'
+        },
 
-        animationDuration: 700,
+        // Use same duration and easing with update to have more consistent animation.
+        updateAnimation: {
+            duration: 500,
+            easing: 'cubicInOut'
+        },
 
-        animationDurationUpdate: 500
+        leaveAnimation: {
+            duration: 500,
+            easing: 'cubicInOut'
+        }
     };
 }
 
diff --git a/src/chart/tree/TreeView.ts b/src/chart/tree/TreeView.ts
index 6f9b44a..d4e3ad9 100644
--- a/src/chart/tree/TreeView.ts
+++ b/src/chart/tree/TreeView.ts
@@ -599,8 +599,7 @@ function removeNodeEdge(
     node: TreeNode,
     data: SeriesData,
     group: graphic.Group,
-    seriesModel: TreeSeriesModel,
-    removeAnimationOpt: AnimationOption
+    seriesModel: TreeSeriesModel
 ) {
     const virtualRoot = data.tree.root;
     const { source, sourceLayout } = getSourceNode(virtualRoot, node);
@@ -642,8 +641,7 @@ function removeNodeEdge(
             }, seriesModel, {
                 cb() {
                     group.remove(edge);
-                },
-                removeOpt: removeAnimationOpt
+                }
             });
         }
         else if (edgeShape === 'polyline' && seriesModel.get('layout') === 'orthogonal') {
@@ -658,8 +656,7 @@ function removeNodeEdge(
             }, seriesModel, {
                 cb() {
                     group.remove(edge);
-                },
-                removeOpt: removeAnimationOpt
+                }
             });
         }
     }
@@ -689,12 +686,6 @@ function removeNode(
 
     const { sourceLayout } = getSourceNode(virtualRoot, node);
 
-    // Use same duration and easing with update to have more consistent animation.
-    const removeAnimationOpt = {
-        duration: seriesModel.get('animationDurationUpdate') as number,
-        easing: seriesModel.get('animationEasingUpdate')
-    };
-
     graphic.removeElement(symbolEl, {
         x: sourceLayout.x + 1,
         y: sourceLayout.y + 1
@@ -702,21 +693,19 @@ function removeNode(
         cb() {
             group.remove(symbolEl);
             data.setItemGraphicEl(dataIndex, null);
-        },
-        removeOpt: removeAnimationOpt
+        }
     });
 
     symbolEl.fadeOut(null, {
-        fadeLabel: true,
-        animation: removeAnimationOpt
+        fadeLabel: true
     });
 
     // remove edge as parent node
     node.children.forEach(childNode => {
-        removeNodeEdge(childNode, data, group, seriesModel, removeAnimationOpt);
+        removeNodeEdge(childNode, data, group, seriesModel);
     });
     // remove edge as child node
-    removeNodeEdge(node, data, group, seriesModel, removeAnimationOpt);
+    removeNodeEdge(node, data, group, seriesModel);
 }
 
 function getEdgeShape(
diff --git a/src/chart/treemap/TreemapSeries.ts b/src/chart/treemap/TreemapSeries.ts
index 043018c..3cc53d6 100644
--- a/src/chart/treemap/TreemapSeries.ts
+++ b/src/chart/treemap/TreemapSeries.ts
@@ -250,9 +250,11 @@ class TreemapSeriesModel extends SeriesModel<TreemapSeriesOption> {
 
         roam: true,
         nodeClick: 'zoomToNode',
-        animation: true,
-        animationDurationUpdate: 900,
-        animationEasing: 'quinticInOut',
+
+        updateAnimation: {
+            duration: 900
+        },
+
         breadcrumb: {
             show: true,
             height: 22,
diff --git a/src/chart/treemap/TreemapView.ts b/src/chart/treemap/TreemapView.ts
index b9e2e9c..ad83bd8 100644
--- a/src/chart/treemap/TreemapView.ts
+++ b/src/chart/treemap/TreemapView.ts
@@ -359,8 +359,8 @@ class TreemapView extends ChartView {
         seriesModel: TreemapSeriesModel,
         reRoot: ReRoot
     ) {
-        const durationOption = seriesModel.get('animationDurationUpdate');
-        const easingOption = seriesModel.get('animationEasing');
+        const durationOption = seriesModel.get(['updateAnimation', 'duration']);
+        const easingOption = seriesModel.get(['updateAnimation', 'easing']);
         // TODO: do not support function until necessary.
         const duration = (isFunction(durationOption) ? 0 : durationOption) || 0;
         const easing = (isFunction(easingOption) ? null : easingOption) || 'cubicOut';
diff --git a/src/component/axisPointer/AxisPointerModel.ts b/src/component/axisPointer/AxisPointerModel.ts
index c776b10..3a9268b 100644
--- a/src/component/axisPointer/AxisPointerModel.ts
+++ b/src/component/axisPointer/AxisPointerModel.ts
@@ -97,7 +97,10 @@ class AxisPointerModel extends ComponentModel<AxisPointerOption> {
         // Do not set 'auto' here, otherwise global animation: false
         // will not effect at this axispointer.
         animation: null,
-        animationDurationUpdate: 200,
+
+        updateAnimation: {
+            duration: 200
+        },
 
         lineStyle: {
             color: '#B9BEC9',
diff --git a/src/component/axisPointer/BaseAxisPointer.ts b/src/component/axisPointer/BaseAxisPointer.ts
index 003fa28..532acba 100644
--- a/src/component/axisPointer/BaseAxisPointer.ts
+++ b/src/component/axisPointer/BaseAxisPointer.ts
@@ -528,7 +528,7 @@ function updateProps(
         moveAnimation
             ? graphic.updateProps(el, props, animationModel as Model<
                 // Ignore animation property
-                Pick<CommonAxisPointerOption, 'animationDurationUpdate' | 'animationEasingUpdate'>
+                Pick<CommonAxisPointerOption, 'updateAnimation'>
             >)
             : (el.stopAnimation(), el.attr(props));
     }
diff --git a/src/component/axisPointer/modelHelper.ts b/src/component/axisPointer/modelHelper.ts
index c991ae0..6325a68 100644
--- a/src/component/axisPointer/modelHelper.ts
+++ b/src/component/axisPointer/modelHelper.ts
@@ -237,7 +237,7 @@ function makeAxisPointerModel(
     const tooltipAxisPointerModel = baseTooltipModel.getModel('axisPointer');
     const fields = [
         'type', 'snap', 'lineStyle', 'shadowStyle', 'label',
-        'animation', 'animationDurationUpdate', 'animationEasingUpdate', 'z'
+        'animation', 'updateAnimation', 'z'
     ] as const;
     const volatileOption = {} as Pick<AxisPointerOption, typeof fields[number]>;
 
diff --git a/src/component/dataZoom/DataZoomModel.ts b/src/component/dataZoom/DataZoomModel.ts
index 12382f3..5bbf83a 100644
--- a/src/component/dataZoom/DataZoomModel.ts
+++ b/src/component/dataZoom/DataZoomModel.ts
@@ -86,7 +86,7 @@ export interface DataZoomOption extends ComponentOption {
     /**
      * Dispatch action by the fixed rate, avoid frequency.
      * default 100. Do not throttle when use null/undefined.
-     * If animation === true and animationDurationUpdate > 0,
+     * If animation === true and updateAnimation.duration > 0,
      * default value is 100, otherwise 20.
      */
     throttle?: number | null | undefined
@@ -387,10 +387,7 @@ class DataZoomModel<Opts extends DataZoomOption = DataZoomOption> extends Compon
             this._autoThrottle = false;
         }
         if (this._autoThrottle) {
-            const globalOption = this.ecModel.option;
-            this.option.throttle = (
-                globalOption.animation && globalOption.animationDurationUpdate > 0
-            ) ? 100 : 20;
+            this.option.throttle = this.ecModel.isAnimationEnabled() ? 100 : 20;
         }
     }
 
diff --git a/src/component/legend/ScrollableLegendModel.ts b/src/component/legend/ScrollableLegendModel.ts
index 7db5032..bd4c005 100644
--- a/src/component/legend/ScrollableLegendModel.ts
+++ b/src/component/legend/ScrollableLegendModel.ts
@@ -49,6 +49,12 @@ export interface ScrollableLegendOption extends LegendOption {
     pageIconSize?: number
     pageTextStyle?: LabelOption
 
+    updateAnimation?: {
+        duration?: number
+    }
+    /**
+     * @deprecated Use updateAnimation.duration instead
+     */
     animationDurationUpdate?: number
 }
 
@@ -102,7 +108,9 @@ class ScrollableLegendModel extends LegendModel<ScrollableLegendOption> {
             color: '#333'
         },
 
-        animationDurationUpdate: 800
+        updateAnimation: {
+            duration: 800
+        }
     });
 };
 
diff --git a/src/component/timeline/SliderTimelineModel.ts b/src/component/timeline/SliderTimelineModel.ts
index ec20bc9..2d5a872 100644
--- a/src/component/timeline/SliderTimelineModel.ts
+++ b/src/component/timeline/SliderTimelineModel.ts
@@ -84,8 +84,10 @@ class SliderTimelineModel extends TimelineModel {
             shadowColor: 'rgba(0, 0, 0, 0.3)',
             // borderColor: 'rgba(194,53,49, 0.5)',
             animation: true,
-            animationDuration: 300,
-            animationEasing: 'quinticInOut'
+            updateAnimation: {
+                duration: 300,
+                easing: 'quinticInOut'
+            }
         },
 
         controlStyle: {
@@ -144,7 +146,7 @@ class SliderTimelineModel extends TimelineModel {
         },
 
         data: []
-    });
+    } as SliderTimelineOption);
 
 }
 
diff --git a/src/component/timeline/SliderTimelineView.ts b/src/component/timeline/SliderTimelineView.ts
index b49bc95..400ec12 100644
--- a/src/component/timeline/SliderTimelineView.ts
+++ b/src/component/timeline/SliderTimelineView.ts
@@ -876,8 +876,8 @@ function pointerMoveTo(
     }
     else {
         const animationCfg = {
-            duration: pointerModel.get('animationDuration', true),
-            easing: pointerModel.get('animationEasing', true)
+            duration: pointerModel.get(['updateAnimation', 'duration'], true),
+            easing: pointerModel.get(['updateAnimation', 'easing'], true)
         };
         pointer.stopAnimation(null, true);
         pointer.animateTo({
diff --git a/src/component/timeline/TimelineModel.ts b/src/component/timeline/TimelineModel.ts
index 0df8f4c..d3c2b9e 100644
--- a/src/component/timeline/TimelineModel.ts
+++ b/src/component/timeline/TimelineModel.ts
@@ -32,7 +32,8 @@ import {
     ColorString,
     CommonTooltipOption,
     CallbackDataParams,
-    ZREasing
+    ZREasing,
+    AnimationOption
 } from '../../util/types';
 import Model from '../../model/Model';
 import GlobalModel, { GlobalModelSetOptionOpts } from '../../model/Global';
@@ -63,8 +64,17 @@ export interface TimelineControlStyle extends ItemStyleOption {
 export interface TimelineCheckpointStyle extends ItemStyleOption,
     SymbolOptionMixin {
     animation?: boolean
+
+    /**
+     * @deprecated Use updateAnimation.duration instead.
+     */
     animationDuration?: number
+    /**
+     * @deprecated Use updateAnimation.easing instead.
+     */
     animationEasing?: ZREasing
+
+    updateAnimation?: Omit<AnimationOption, 'delay'>
 }
 
 interface TimelineLineStyleOption extends LineStyleOption {
diff --git a/src/component/tooltip/TooltipModel.ts b/src/component/tooltip/TooltipModel.ts
index 413b52f..f1f2c00 100644
--- a/src/component/tooltip/TooltipModel.ts
+++ b/src/component/tooltip/TooltipModel.ts
@@ -153,8 +153,11 @@ class TooltipModel extends ComponentModel<TooltipOption> {
             axis: 'auto',
 
             animation: 'auto',
-            animationDurationUpdate: 200,
-            animationEasingUpdate: 'exponentialOut',
+
+            updateAnimation: {
+                duration: 200,
+                easing: 'exponentialOut'
+            },
 
             crossStyle: {
                 color: '#999',
diff --git a/src/model/globalDefault.ts b/src/model/globalDefault.ts
index 304a550..4052639 100644
--- a/src/model/globalDefault.ts
+++ b/src/model/globalDefault.ts
@@ -105,16 +105,24 @@ export default {
     // Default is source-over
     blendMode: null,
 
+    animation: 'auto',
+
     stateAnimation: {
         duration: 300,
         easing: 'cubicOut'
     },
-
-    animation: 'auto',
-    animationDuration: 1000,
-    animationDurationUpdate: 500,
-    animationEasing: 'cubicInOut',
-    animationEasingUpdate: 'cubicInOut',
+    enterAnimation: {
+        duration: 1000,
+        easing: 'cubicInOut'
+    },
+    updateAnimation: {
+        duration: 500,
+        easing: 'cubicInOut'
+    },
+    leaveAnimation: {
+        duration: 200,
+        easing: 'cubicOut'
+    },
 
     animationThreshold: 2000,
 
diff --git a/src/preprocessor/backwardCompat.ts b/src/preprocessor/backwardCompat.ts
index faa874f..0ab2baf 100644
--- a/src/preprocessor/backwardCompat.ts
+++ b/src/preprocessor/backwardCompat.ts
@@ -21,7 +21,7 @@ import {each, isArray, isObject, isTypedArray, defaults} from 'zrender/src/core/
 import compatStyle from './helper/compatStyle';
 import {normalizeToArray} from '../util/model';
 import { Dictionary } from 'zrender/src/core/types';
-import { ECUnitOption } from '../util/types';
+import { AnimationOptionMixin, ECUnitOption } from '../util/types';
 import type { BarSeriesOption } from '../chart/bar/BarSeries';
 import type { PieSeriesOption } from '../chart/pie/PieSeries';
 import { deprecateLog, deprecateReplaceLog } from '../util/log';
@@ -141,6 +141,30 @@ function traverseTree(data: any[], cb: Function) {
     }
 }
 
+function lowerCase<T extends string>(str: T) {
+    return str.toLowerCase() as `${Lowercase<T>}`;
+}
+
+function compatAnimation(animationOpt: AnimationOptionMixin) {
+    if (!animationOpt) {
+        return;
+    }
+    each(['', 'Update'] as const, (animationType) => {
+        each(['Easing', 'Duration', 'Delay'] as const, (animationConfigItem) => {
+            const legacyProp = `animation${animationConfigItem}${animationType}` as const;
+            if (animationOpt[legacyProp] != null) {
+                const animationTypeNew = `${lowerCase(animationType || 'enter')}Animation` as const;
+                animationOpt[animationTypeNew] = animationOpt[animationTypeNew] || {};
+                (animationOpt[animationTypeNew] as any)[lowerCase(animationConfigItem)] = animationOpt[legacyProp];
+
+                if (__DEV__) {
+                    deprecateReplaceLog(legacyProp, `${animationTypeNew}.${lowerCase(animationConfigItem)}`);
+                }
+            }
+        });
+    });
+}
+
 export default function globalBackwardCompat(option: ECUnitOption, isTheme?: boolean) {
     compatStyle(option, isTheme);
 
@@ -251,12 +275,18 @@ export default function globalBackwardCompat(option: ECUnitOption, isTheme?: boo
             }
         }
 
+        // Animation
+        compatAnimation(seriesOpt);
+
         compatLayoutProperties(seriesOpt);
     });
 
     // dataRange has changed to visualMap
     if (option.dataRange) {
         option.visualMap = option.dataRange;
+        if (__DEV__) {
+            deprecateReplaceLog('dataRange', 'visualMap');
+        }
     }
 
     each(COMPATITABLE_COMPONENTS, function (componentName) {
@@ -270,4 +300,21 @@ export default function globalBackwardCompat(option: ECUnitOption, isTheme?: boo
             });
         }
     });
+
+    // Handling animations.
+    compatAnimation(option);
+    // Axis pointers
+    each(['xAxis', 'yAxis', 'angleAxis', 'radiusAxis', 'tooltip'], componentName => {
+        each(option[componentName], (componentOpt: any) => {
+            compatAnimation(componentOpt && componentOpt.axisPointer);
+        });
+    });
+    each(option.grid, (gridOption: any) => {
+        compatAnimation(gridOption && gridOption.tooltip && gridOption.tooltip.axisPointer);
+    });
+    // Scrollable legend.
+    each(option.legend, compatAnimation);
+    each(option.timeline, (timelineOpt: any) => {
+        compatAnimation(timelineOpt && timelineOpt.checkpointStyle);
+    });
 }
\ No newline at end of file
diff --git a/src/util/types.ts b/src/util/types.ts
index 95e5b50..46d088d 100644
--- a/src/util/types.ts
+++ b/src/util/types.ts
@@ -814,10 +814,10 @@ export type AnimationDelayCallbackParam = {
 export type AnimationDurationCallback = (idx: number) => number;
 export type AnimationDelayCallback = (idx: number, params?: AnimationDelayCallbackParam) => number;
 
-export interface AnimationOption {
-    duration?: number
+export interface AnimationOption<TCb = never> {
+    duration?: number | (TCb extends never ? never : AnimationDurationCallback)
     easing?: AnimationEasing
-    delay?: number
+    delay?: number | (TCb extends never ? never : AnimationDelayCallback)
     // additive?: boolean
 }
 
@@ -833,34 +833,34 @@ export interface AnimationOptionMixin {
      * Disable animation when the number of elements exceeds the threshold
      */
     animationThreshold?: number
-    // For init animation
+
+    enterAnimation?: AnimationOption<true>
+    updateAnimation?: AnimationOption<true>
+    leaveAnimation?: AnimationOption<true>
+
     /**
-     * Duration of initialize animation.
-     * Can be a callback to specify duration of each element
+     * @deprecated Use enterAnimation.duration instead
      */
     animationDuration?: number | AnimationDurationCallback
     /**
-     * Easing of initialize animation
+     * @deprecated Use enterAnimation.easing instead
      */
     animationEasing?: AnimationEasing
     /**
-     * Delay of initialize animation
-     * Can be a callback to specify duration of each element
+     * @deprecated Use enterAnimation.delay instead
      */
     animationDelay?: number | AnimationDelayCallback
-    // For update animation
+
     /**
-     * Delay of data update animation.
-     * Can be a callback to specify duration of each element
+     * @deprecated Use updateAnimation.duration instead
      */
     animationDurationUpdate?: number | AnimationDurationCallback
     /**
-     * Easing of data update animation.
+     * @deprecated Use updateAnimation.easing instead
      */
     animationEasingUpdate?: AnimationEasing
     /**
-     * Delay of data update animation.
-     * Can be a callback to specify duration of each element
+     * @deprecated Use updateAnimation.delay instead
      */
     animationDelayUpdate?: number | AnimationDelayCallback
 }
@@ -1394,7 +1394,16 @@ export interface CommonAxisPointerOption {
         formatter?: string | ((params: LabelFormatterParams) => string)
     }
     animation?: boolean | 'auto'
+
+    updateAnimation?: Omit<AnimationOption, 'delay'>
+
+    /**
+     * @deprecated Use updateAnimation.duration
+     */
     animationDurationUpdate?: number
+    /**
+     * @deprecated Use updateAnimation.duration
+     */
     animationEasingUpdate?: ZREasing
 
     /**

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org