I'm from/to.
Click me to resize.
I'm by.
Click me to resize.
function toggler(el, attributes, duration, method) {
this.init(el, attributes, duration, method);
// reverse the attributes so it works as expected the first time
// possibly a better way to do this is to register onComplete and
// toggle values.
this.switchAttrs();
}
toggler.prototype = new YAHOO.util.Anim();
toggler.prototype.toggle = function() {
this.switchAttrs();
this.animate();
};
/* swaps the from and to values or negates the by value. TODO possibly
* check the from and to values to see if one is missing and use the
* current value of this trait to fill in the missing value. */
toggler.prototype.switchAttrs = function() {
for (attr in this.attributes) {
if (this.attributes[attr].by) {
this.attributes[attr].by = -(this.attributes[attr].by);
} else {
var tmp = this.attributes[attr].from;
this.attributes[attr].from = this.attributes[attr].to;
this.attributes[attr].to = tmp;
}
}
};