Animal
11 Nov 2006, 9:12 AM
I just came up with the requirement to highlight a certain element, like "click this", or "this might be what you're looking for".
So here's a method I whipped up for the Actor class.
/**
* Show a ripple of exploding, attenuating borders to draw attention to an Element.
* @param {Number[i]} color (optional) The color of the border.
* @param {[i]Number} count (optional) How many ripples.
* @param {Float} duration (optional) How long each ripple takes to expire
*/
YAHOO.ext.Actor.prototype.explode = function(color, count, duration){
color = color || "red";
count = count || 3;
var box = this.getBox();
// Build a function to animate an exploding, attenuating border
var explodeFn = function()
{
if (count <= 0)
return;
var explodeProxy = new YAHOO.ext.Actor(YAHOO.ext.DomHelper.append(document.body,
{
tag:"div",
style:
{
visbility:"hidden",
position:"absolute",
zIndex:this.getStyle("zIndex"),
border:"0px solid " + color
}
}));
explodeProxy.animate(
{
top:{from:box.y, to:box.y - 20},
left:{from:box.x, to:box.x - 20},
borderWidth:{from:0, to:10},
opacity:{from:1, to:0},
height:{from:box.height, to:(box.height + 20)},
width:{from:box.width, to:(box.width + 20)}
}, duration || 0.5, function()
{
explodeProxy.dom.parentNode.removeChild(explodeProxy.dom);
});
if (--count > 0)
setTimeout(explodeFn, 250);
}.createDelegate(this);
explodeFn(count || 3);
}
Worth adding?
So here's a method I whipped up for the Actor class.
/**
* Show a ripple of exploding, attenuating borders to draw attention to an Element.
* @param {Number[i]} color (optional) The color of the border.
* @param {[i]Number} count (optional) How many ripples.
* @param {Float} duration (optional) How long each ripple takes to expire
*/
YAHOO.ext.Actor.prototype.explode = function(color, count, duration){
color = color || "red";
count = count || 3;
var box = this.getBox();
// Build a function to animate an exploding, attenuating border
var explodeFn = function()
{
if (count <= 0)
return;
var explodeProxy = new YAHOO.ext.Actor(YAHOO.ext.DomHelper.append(document.body,
{
tag:"div",
style:
{
visbility:"hidden",
position:"absolute",
zIndex:this.getStyle("zIndex"),
border:"0px solid " + color
}
}));
explodeProxy.animate(
{
top:{from:box.y, to:box.y - 20},
left:{from:box.x, to:box.x - 20},
borderWidth:{from:0, to:10},
opacity:{from:1, to:0},
height:{from:box.height, to:(box.height + 20)},
width:{from:box.width, to:(box.width + 20)}
}, duration || 0.5, function()
{
explodeProxy.dom.parentNode.removeChild(explodeProxy.dom);
});
if (--count > 0)
setTimeout(explodeFn, 250);
}.createDelegate(this);
explodeFn(count || 3);
}
Worth adding?