11 Fx.Elements allows you to apply any number of styles transitions to a selection of elements. Includes colors (must be in hex format).
14 elements - a collection of elements the effects will be applied to.
15 options - same as <Fx.Base> options.
18 Fx.Elements = Fx.Base.extend({
20 initialize: function(elements, options){
21 this.elements = $$(elements);
26 for (var i in this.from){
27 var iFrom = this.from[i], iTo = this.to[i], iCss = this.css[i], iNow = this.now[i] = {};
28 for (var p in iFrom) iNow[p] = iCss[p].getNow(iFrom[p], iTo[p], this);
36 var iTo = to[i], iCss = this.css[i] = {}, iParsed = parsed[i] = {};
38 iCss[p] = Fx.CSS.select(p, iTo[p]);
39 iParsed[p] = iCss[p].parse(iTo[p]);
42 return this.parent(parsed);
47 Applies the passed in style transitions to each object named (see example). Each item in the collection is refered to as a numerical string ("1" for instance). The first item is "0", the second "1", etc.
51 var myElementsEffects = new Fx.Elements($$('a'));
52 myElementsEffects.start({
53 '0': { //let's change the first element's opacity and width
57 '4': { //and the fifth one's opacity
65 if (this.timer && this.options.wait) return this;
68 var from = {}, to = {};
70 var iProps = obj[i], iFrom = from[i] = {}, iTo = to[i] = {}, iCss = this.css[i] = {};
71 for (var p in iProps){
72 var parsed = Fx.CSS.parse(this.elements[i], p, iProps[p]);
73 iFrom[p] = parsed.from;
78 return this.parent(from, to);
82 for (var i in this.now){
83 var iNow = this.now[i], iCss = this.css[i];
84 for (var p in iNow) this.elements[i].setStyle(p, iCss[p].getValue(iNow[p], this.options.unit, p));