Skip to content

Commit

Permalink
fix(g-canvas): animation for marker should be effective, close #236
Browse files Browse the repository at this point in the history
  • Loading branch information
dengfuping committed Oct 29, 2019
1 parent 5d7b428 commit 1e6403b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/g-canvas/src/shape/marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class Marker extends ShapeBase {
// 更新属性时,检测是否更改了 path
onAttrChange(name: string, value: any, originValue: any) {
super.onAttrChange(name, value, originValue);
if (name === 'symbol') {
// symbol 更改时,清理缓存
if (['symbol', 'x', 'y', 'r'].indexOf(name) !== -1) {
// path 相关属性更改时,清理缓存
this._resetParamsCache();
}
}
Expand Down
50 changes: 50 additions & 0 deletions packages/g-canvas/tests/bugs/issue-236-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const expect = require('chai').expect;
import Canvas from '../../src/canvas';

const dom = document.createElement('div');
document.body.appendChild(dom);
dom.id = 'c1';

describe('#236', () => {
const canvas = new Canvas({
container: dom,
width: 600,
height: 600,
});

it('animation for marker should be effective', (done) => {
const shape = canvas.addShape('marker', {
attrs: {
lineWidth: 1,
fill: '#1890ff',
r: 16.6,
opacity: 0.3,
x: 247.22381317138678,
y: 153.66500000000002,
symbol: 'circle',
},
});

shape.animate(
{
fill: '#1890ff',
lineWidth: 1,
opacity: 0.3,
r: 16.6,
stroke: '#1890ff',
symbol: 'circle',
x: 457.20191545758945,
y: 153.66500000000002,
},
{
duration: 100,
}
);

setTimeout(() => {
expect(shape.attr('x')).eqls(457.20191545758945);
expect(shape.attr('y')).eqls(153.66500000000002);
done();
}, 120);
});
});

0 comments on commit 1e6403b

Please sign in to comment.