MCPcopy
hub / github.com/apache/echarts / applyPropsDirectly

Function applyPropsDirectly

src/animation/customGraphicTransition.ts:259–303  ·  view source on GitHub ↗
(
    el: Element,
    // Can be null/undefined
    allPropsFinal: ElementProps,
    clearStyle: boolean
)

Source from the content-addressed store, hash-verified

257
258
259function applyPropsDirectly(
260 el: Element,
261 // Can be null/undefined
262 allPropsFinal: ElementProps,
263 clearStyle: boolean
264) {
265 const styleOpt = (allPropsFinal as Displayable).style;
266 if (!el.isGroup && styleOpt) {
267 if (clearStyle) {
268 (el as Displayable).useStyle({});
269
270 // When style object changed, how to trade the existing animation?
271 // It is probably complicated and not needed to cover all the cases.
272 // But still need consider the case:
273 // (1) When using init animation on `style.opacity`, and before the animation
274 // ended users triggers an update by mousewhel. At that time the init
275 // animation should better be continued rather than terminated.
276 // So after `useStyle` called, we should change the animation target manually
277 // to continue the effect of the init animation.
278 // (2) PENDING: If the previous animation targeted at a `val1`, and currently we need
279 // to update the value to `val2` and no animation declared, should be terminate
280 // the previous animation or just modify the target of the animation?
281 // Therotically That will happen not only on `style` but also on `shape` and
282 // `transfrom` props. But we haven't handle this case at present yet.
283 // (3) PENDING: Is it proper to visit `animators` and `targetName`?
284 const animators = el.animators;
285 for (let i = 0; i < animators.length; i++) {
286 const animator = animators[i];
287 // targetName is the "topKey".
288 if (animator.targetName === 'style') {
289 animator.changeTarget((el as Displayable).style);
290 }
291 }
292 }
293 (el as Displayable).setStyle(styleOpt);
294 }
295
296 if (allPropsFinal) {
297 // Not set style here.
298 (allPropsFinal as DisplayableProps).style = null;
299 // Set el to the final state firstly.
300 allPropsFinal && el.attr(allPropsFinal);
301 (allPropsFinal as DisplayableProps).style = styleOpt;
302 }
303}
304
305function applyPropsTransition(
306 el: Element,

Callers 1

applyUpdateTransitionFunction · 0.85

Calls 1

setStyleMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…