Skip to content

Commit

Permalink
fix: fix the draw error caused by smooth area animation. Closed #373.
Browse files Browse the repository at this point in the history
  • Loading branch information
simaQ committed Oct 15, 2018
1 parent 1ba3b5b commit 407fdf5
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/geom/shape/area.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ function equals(v1, v2) {
return Math.abs(v1 - v2) < 0.00001;
}

function notEmpty(value) {
return !isNaN(value) && !Util.isNil(value);
}

function filterPoints(points) {
const filteredPoints = [];
// filter the point which x or y is NaN
for (let i = 0, len = points.length; i < len; i++) {
const point = points[i];
if (notEmpty(point.x) && notEmpty(point.y)) {
filteredPoints.push(point);
}
}

return filteredPoints;
}

function equalsCenter(points, center) {
let eqls = true;
Util.each(points, function(point) {
Expand All @@ -33,7 +50,8 @@ function drawRectShape(topPoints, bottomPoints, container, style, isSmooth) {
[ 0, 0 ],
[ 1, 1 ]
];
const points = this._attrs.attrs.points;
const points = filterPoints(this._attrs.attrs.points);

const pointsLen = points.length;
const topPoints = points.slice(0, pointsLen / 2);
const bottomPoints = points.slice(pointsLen / 2, pointsLen);
Expand All @@ -56,7 +74,7 @@ function drawRectShape(topPoints, bottomPoints, container, style, isSmooth) {
context.closePath();
},
calculateBox() {
const points = this._attrs.attrs.points;
const points = filterPoints(this._attrs.attrs.points);
return bbox.getBBoxFromPoints(points);
}
});
Expand Down

0 comments on commit 407fdf5

Please sign in to comment.