Skip to content

Commit

Permalink
enhancement #649
Browse files Browse the repository at this point in the history
  • Loading branch information
kener committed Nov 18, 2014
1 parent b2a4989 commit 5efc825
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/chart/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@ define(function (require) {
var duration = lastShapeList.length > 0
? 500 : this.query(this.option, 'animationDuration');
var easing = this.query(this.option, 'animationEasing');
var delay;
var key;
var oldMap = {};
var newMap = {};
Expand Down Expand Up @@ -1383,7 +1384,12 @@ define(function (require) {
else {
// 新有旧没有 添加并动画过渡
//this._animateAdd(newMap[key], duration, easing);
this._animateMod(false, newMap[key], duration, easing);
delay = (this.type == ecConfig.CHART_TYPE_LINE
|| this.type == ecConfig.CHART_TYPE_RADAR)
&& key.indexOf('icon') != 0
? duration / 2
: 0;
this._animateMod(false, newMap[key], duration, easing, delay);
}
}
this.zr.refresh();
Expand Down Expand Up @@ -1418,7 +1424,7 @@ define(function (require) {
/**
* 动画过渡
*/
_animateMod: function (oldShape, newShape, duration, easing) {
_animateMod: function (oldShape, newShape, duration, easing, delay) {
switch (newShape.type) {
case 'broken-line' :
case 'half-smooth-polygon' :
Expand All @@ -1428,7 +1434,7 @@ define(function (require) {
ecAnimation.rectangle(this.zr, oldShape, newShape, duration, easing);
break;
case 'icon' :
ecAnimation.icon(this.zr, oldShape, newShape, duration, easing);
ecAnimation.icon(this.zr, oldShape, newShape, duration, easing, delay);
break;
case 'candle' :
if (duration > 500) {
Expand Down
5 changes: 3 additions & 2 deletions src/util/ecAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ define(function (require) {
* @param {number} duration
* @param {tring} easing
*/
function icon(zr, oldShape, newShape, duration, easing) {
function icon(zr, oldShape, newShape, duration, easing, delay) {
// 避免markPoint特效取值在动画帧上
newShape.style._x = newShape.style.x;
newShape.style._y = newShape.style.y;
Expand All @@ -432,9 +432,10 @@ define(function (require) {
if (!oldShape) { // add
var x = newShape._x || 0;
var y = newShape._y || 0;
newShape.scale = [0, 0, x, y];
newShape.scale = [0.01, 0.01, x, y];
zr.addShape(newShape);
zr.animate(newShape.id, '')
.delay(delay)
.when(
duration,
{scale : [1, 1, x, y]}
Expand Down

0 comments on commit 5efc825

Please sign in to comment.