(
animationType: 'enter' | 'update' | 'leave',
el: Element<Props>,
props: Props,
animatableModel?: Model<AnimationOptionMixin> & {
getAnimationDelayParams?: (el: Element<Props>, dataIndex: number) => AnimationDelayCallbackParam
},
dataIndex?: AnimateOrSetPropsOption['dataIndex'] | AnimateOrSetPropsOption['cb'] | AnimateOrSetPropsOption,
cb?: AnimateOrSetPropsOption['cb'] | AnimateOrSetPropsOption['during'],
during?: AnimateOrSetPropsOption['during']
)
| 125 | } |
| 126 | |
| 127 | function animateOrSetProps<Props>( |
| 128 | animationType: 'enter' | 'update' | 'leave', |
| 129 | el: Element<Props>, |
| 130 | props: Props, |
| 131 | animatableModel?: Model<AnimationOptionMixin> & { |
| 132 | getAnimationDelayParams?: (el: Element<Props>, dataIndex: number) => AnimationDelayCallbackParam |
| 133 | }, |
| 134 | dataIndex?: AnimateOrSetPropsOption['dataIndex'] | AnimateOrSetPropsOption['cb'] | AnimateOrSetPropsOption, |
| 135 | cb?: AnimateOrSetPropsOption['cb'] | AnimateOrSetPropsOption['during'], |
| 136 | during?: AnimateOrSetPropsOption['during'] |
| 137 | ) { |
| 138 | let isFrom = false; |
| 139 | let removeOpt: AnimationOption; |
| 140 | if (isFunction(dataIndex)) { |
| 141 | during = cb; |
| 142 | cb = dataIndex; |
| 143 | dataIndex = null; |
| 144 | } |
| 145 | else if (isObject(dataIndex)) { |
| 146 | cb = dataIndex.cb; |
| 147 | during = dataIndex.during; |
| 148 | isFrom = dataIndex.isFrom; |
| 149 | removeOpt = dataIndex.removeOpt; |
| 150 | dataIndex = dataIndex.dataIndex; |
| 151 | } |
| 152 | |
| 153 | const isRemove = (animationType === 'leave'); |
| 154 | |
| 155 | if (!isRemove) { |
| 156 | // Must stop the remove animation. |
| 157 | el.stopAnimation('leave'); |
| 158 | } |
| 159 | |
| 160 | const animationConfig = getAnimationConfig( |
| 161 | animationType, |
| 162 | animatableModel, |
| 163 | dataIndex as number, |
| 164 | isRemove ? (removeOpt || {}) : null, |
| 165 | (animatableModel && animatableModel.getAnimationDelayParams) |
| 166 | ? animatableModel.getAnimationDelayParams(el, dataIndex as number) |
| 167 | : null |
| 168 | ); |
| 169 | if (animationConfig && animationConfig.duration > 0) { |
| 170 | const duration = animationConfig.duration; |
| 171 | const animationDelay = animationConfig.delay; |
| 172 | const animationEasing = animationConfig.easing; |
| 173 | |
| 174 | const animateConfig: ElementAnimateConfig = { |
| 175 | duration: duration as number, |
| 176 | delay: animationDelay as number || 0, |
| 177 | easing: animationEasing, |
| 178 | done: cb, |
| 179 | force: !!cb || !!during, |
| 180 | // Set to final state in update/init animation. |
| 181 | // So the post processing based on the path shape can be done correctly. |
| 182 | setToFinal: !isRemove, |
| 183 | scope: animationType, |
| 184 | during: during |
no test coverage detected
searching dependent graphs…