Skip to content

Commit

Permalink
fix(animate waveIn): 修复 waveIn 动画 最后没有给 element 附上更新后样式的问题 (#4000)
Browse files Browse the repository at this point in the history
Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com>
  • Loading branch information
ai-qing-hai and ai-qing-hai committed Jun 24, 2022
1 parent 17c146d commit beb9766
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/animate/animation/wave-in.ts
Expand Up @@ -19,6 +19,11 @@ export function waveIn(element: IShape | IGroup, animateCfg: GAnimateCfg, cfg: A
attrs: startState,
}) as IShape; // 为 shape 设置剪切区域

// 更新 动画 获取了 toAttrs 需要重新更新上去
if (cfg.toAttrs) {
element.attr(cfg.toAttrs);
}

// 对剪切图形做动画
clipShape.animate(endState, {
...animateCfg,
Expand Down
61 changes: 61 additions & 0 deletions tests/bugs/3694-spec.ts
@@ -0,0 +1,61 @@

import { Chart } from '../../src';
import { createDiv } from '../util/dom';

describe('#3694', () => {
const data = [
{ term: 'Zombieland', count: 9 },
];

const chart = new Chart({
container: createDiv(),
autoFit: true,
height: 500,
padding: 50,
});

chart.data(data);

chart.scale({
count: {
min: 1,
max: 10,
},
});
chart.tooltip(false)
chart.coordinate('theta', {
innerRadius: 0.7,
radius: 1
})

chart
.interval()
.position('term*count')
.shape('line')
.style({
lineAppendWidth: 10,
}) // 线状柱状图
.animate({
update: {
animation: 'wave-in', // 动画名称
easing: 'easeQuadIn', // 动画缓动效果
delay: 100, // 动画延迟执行时间
duration: 500 // 动画执行时间
},
})


chart.render();

it('wave-in animation update', () => {
const shape = chart.canvas.findAll((e) => e.cfg.type === 'path')[0];
const path = shape.attr('path');

chart.changeData([{
count: 5,
term: "Zombieland"
}]);

expect(path).not.toMatchObject(shape.attr('path'));
});
});

0 comments on commit beb9766

Please sign in to comment.