(
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
)
| 56 | * Return null if animation is disabled. |
| 57 | */ |
| 58 | export function getAnimationConfig( |
| 59 | animationType: 'enter' | 'update' | 'leave', |
| 60 | animatableModel: Model<AnimationOptionMixin>, |
| 61 | dataIndex: number, |
| 62 | // Extra opts can override the option in animatable model. |
| 63 | extraOpts?: Pick<ElementAnimateConfig, 'easing' | 'duration' | 'delay'>, |
| 64 | // TODO It's only for pictorial bar now. |
| 65 | extraDelayParams?: unknown |
| 66 | ): Pick<ElementAnimateConfig, 'easing' | 'duration' | 'delay'> | null { |
| 67 | let animationPayload: PayloadAnimationPart; |
| 68 | // Check if there is global animation configuration from dataZoom/resize can override the config in option. |
| 69 | // If animation is enabled. Will use this animation config in payload. |
| 70 | // If animation is disabled. Just ignore it. |
| 71 | if (animatableModel && animatableModel.ecModel) { |
| 72 | const updatePayload = animatableModel.ecModel.getUpdatePayload(); |
| 73 | animationPayload = (updatePayload && updatePayload.animation) as PayloadAnimationPart; |
| 74 | } |
| 75 | const animationEnabled = animatableModel && animatableModel.isAnimationEnabled(); |
| 76 | |
| 77 | const isUpdate = animationType === 'update'; |
| 78 | |
| 79 | if (animationEnabled) { |
| 80 | let duration: number | Function; |
| 81 | let easing: AnimationEasing; |
| 82 | let delay: number | Function; |
| 83 | if (extraOpts) { |
| 84 | duration = retrieve2(extraOpts.duration, 200); |
| 85 | easing = retrieve2(extraOpts.easing, 'cubicOut'); |
| 86 | delay = 0; |
| 87 | } |
| 88 | else { |
| 89 | duration = animatableModel.getShallow( |
| 90 | isUpdate ? 'animationDurationUpdate' : 'animationDuration' |
| 91 | ); |
| 92 | easing = animatableModel.getShallow( |
| 93 | isUpdate ? 'animationEasingUpdate' : 'animationEasing' |
| 94 | ); |
| 95 | delay = animatableModel.getShallow( |
| 96 | isUpdate ? 'animationDelayUpdate' : 'animationDelay' |
| 97 | ); |
| 98 | } |
| 99 | // animation from payload has highest priority. |
| 100 | if (animationPayload) { |
| 101 | animationPayload.duration != null && (duration = animationPayload.duration); |
| 102 | animationPayload.easing != null && (easing = animationPayload.easing); |
| 103 | animationPayload.delay != null && (delay = animationPayload.delay); |
| 104 | } |
| 105 | if (isFunction(delay)) { |
| 106 | delay = delay( |
| 107 | dataIndex as number, |
| 108 | extraDelayParams |
| 109 | ); |
| 110 | } |
| 111 | if (isFunction(duration)) { |
| 112 | duration = duration(dataIndex as number); |
| 113 | } |
| 114 | const config = { |
| 115 | duration: duration as number || 0, |
no test coverage detected
searching dependent graphs…