| 1 |
define(["dojo/_base/connect", "dojo/_base/declare", "./PlotAction", |
| 2 |
"dojo/fx", "dojo/fx/easing", "dojox/gfx/matrix", "dojox/gfx/fx"], |
| 3 |
function(hub, declare, PlotAction, df, dfe, m, gf){ |
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
var DEFAULT_SHIFT = 3; |
| 20 |
|
| 21 |
return declare("dojox.charting.action2d.Shake", PlotAction, { |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
defaultParams: { |
| 27 |
duration: 400, |
| 28 |
easing: dfe.backOut, |
| 29 |
shiftX: DEFAULT_SHIFT, |
| 30 |
shiftY: DEFAULT_SHIFT |
| 31 |
}, |
| 32 |
optionalParams: {}, |
| 33 |
|
| 34 |
constructor: function(chart, plot, kwArgs){ |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
if(!kwArgs){ kwArgs = {}; } |
| 44 |
this.shiftX = typeof kwArgs.shiftX == "number" ? kwArgs.shiftX : DEFAULT_SHIFT; |
| 45 |
this.shiftY = typeof kwArgs.shiftY == "number" ? kwArgs.shiftY : DEFAULT_SHIFT; |
| 46 |
|
| 47 |
this.connect(); |
| 48 |
}, |
| 49 |
|
| 50 |
process: function(o){ |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
if(!o.shape || !(o.type in this.overOutEvents)){ return; } |
| 56 |
|
| 57 |
var runName = o.run.name, index = o.index, vector = [], anim; |
| 58 |
|
| 59 |
if(runName in this.anim){ |
| 60 |
anim = this.anim[runName][index]; |
| 61 |
}else{ |
| 62 |
this.anim[runName] = {}; |
| 63 |
} |
| 64 |
|
| 65 |
if(anim){ |
| 66 |
anim.action.stop(true); |
| 67 |
}else{ |
| 68 |
this.anim[runName][index] = anim = {}; |
| 69 |
} |
| 70 |
|
| 71 |
var kwArgs = { |
| 72 |
shape: o.shape, |
| 73 |
duration: this.duration, |
| 74 |
easing: this.easing, |
| 75 |
transform: [ |
| 76 |
{name: "translate", start: [this.shiftX, this.shiftY], end: [0, 0]}, |
| 77 |
m.identity |
| 78 |
] |
| 79 |
}; |
| 80 |
if(o.shape){ |
| 81 |
vector.push(gf.animateTransform(kwArgs)); |
| 82 |
} |
| 83 |
if(o.oultine){ |
| 84 |
kwArgs.shape = o.outline; |
| 85 |
vector.push(gf.animateTransform(kwArgs)); |
| 86 |
} |
| 87 |
if(o.shadow){ |
| 88 |
kwArgs.shape = o.shadow; |
| 89 |
vector.push(gf.animateTransform(kwArgs)); |
| 90 |
} |
| 91 |
|
| 92 |
if(!vector.length){ |
| 93 |
delete this.anim[runName][index]; |
| 94 |
return; |
| 95 |
} |
| 96 |
|
| 97 |
anim.action = df.combine(vector); |
| 98 |
if(o.type == "onmouseout"){ |
| 99 |
hub.connect(anim.action, "onEnd", this, function(){ |
| 100 |
if(this.anim[runName]){ |
| 101 |
delete this.anim[runName][index]; |
| 102 |
} |
| 103 |
}); |
| 104 |
} |
| 105 |
anim.action.play(); |
| 106 |
} |
| 107 |
}); |
| 108 |
}); |