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