Skip to content

Commit

Permalink
splice -1 bugfix, fix apache/echarts#1352
Browse files Browse the repository at this point in the history
  • Loading branch information
pissang committed Mar 12, 2015
1 parent 2ad6042 commit d0301a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ define(function(require) {
Group.prototype.removeChild = function(child) {
var idx = util.indexOf(this._children, child);

this._children.splice(idx, 1);
if (idx >= 0) {
this._children.splice(idx, 1);
}
child.parent = null;

if (this._storage) {
Expand Down
10 changes: 8 additions & 2 deletions src/zrender.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,10 @@ define(

var animator = this.animation.animate(target, { loop: loop })
.done(function () {
animators.splice(el.__animators.indexOf(animator), 1);
var idx = util.indexOf(el.__animators, animator);
if (idx >= 0) {
animators.splice(idx, 1);
}
if (animators.length === 0) {
// 从animatingElements里移除
var idx = util.indexOf(animatingElements, el);
Expand Down Expand Up @@ -454,7 +457,10 @@ define(
}
if (len > 0) {
var animatingElements = this.animatingElements;
animatingElements.splice(animatingElements.indexOf(el), 1);
var idx = util.indexOf(animatingElements, el);
if (idx >= 0) {
animatingElements.splice(idx, 1);
}
}

animators.length = 0;
Expand Down

0 comments on commit d0301a7

Please sign in to comment.