source: [view]
var anims = [],
n = args.node,
duration = args.duration || 1000,
scaleX = args.scaleX || 1.2,
scaleY = args.scaleY || .6,
ds = dojo.style,
oldPos = ds(n, "position"),
newPos = "absolute",
oldTop = ds(n, "top"),
combinedAnims = [],
bTime = 0,
round = Math.round,
jumpHeight = args.jumpHeight || 70
;
if(oldPos !== "absolute"){
newPos = "relative";
}
var a1 = dojo.animateProperty({
node: n,
duration: duration / 6,
properties: {
transform: { start: "scale(1, 1)", end: "scale(" + scaleX + ", " + scaleY + ")" }
}
});
dojo.connect(a1, "onBegin", function(){
ds(n, {
transformOrigin: "50% 100%",
position: newPos
});
});
anims.push(a1);
var a2 = dojo.animateProperty({
node: n,
duration: duration / 6,
properties: {
transform: { end: "scale(1, 1)", start: "scale(" + scaleX + ", " + scaleY + ")" }
}
});
combinedAnims.push(a2);
combinedAnims.push(new dojo.Animation(dojo.mixin({
curve: [],
duration: duration / 3,
delay: duration / 12,
onBegin: function(){
bTime = (new Date).getTime();
},
onAnimate: function(){
var cTime = (new Date).getTime();
ds(n, {
top: parseInt(ds(n, "top")) - round(jumpHeight*((cTime-bTime)/this.duration)) + "px"
});
bTime = cTime;
}
}, args)));
anims.push(dojo.fx.combine(combinedAnims));
anims.push(dojo.animateProperty(dojo.mixin({
duration: duration / 3,
onEnd: function(){
ds(n, {
position: oldPos
});
},
properties:{
top: oldTop
}
}, args)));
anims.push(a1);
anims.push(a2);
return dojo.fx.chain(anims);