You can if the syntax is correct. The most recent code is setup like a standard jQuery plugin in that it has defaults and takes configuration options which will override those defaults as an argument. So, although they could be inserted if done so in a syntactically correct manner, you don't really need if statements within the defaults object. Any property of the defaults object which also appears within the configuration object will be overridden by it. In other words, the config object takes precedence and the defaults are just there as fallbacks in case no value is specified for that property in the config.
The net effect is as though, for every item in the defaults object the script is already performing an if action, which is:
If there's no value set for this option in the config object, use this value.
The config object is in the new rise_fall() call and can include any or all of the properties that appear in the defaults. Those that are included will override the defaults for that call. If it's absent, it's assumed to be empty and no substitutions will be made. Example config objects (each config object is highlighted):
Code:
leaves = new rise_fall({speed: 60, Amount: 10, accumulate: 255});
Code:
bubbles = new rise_fall({speed: 75, sway: 20, dir: -1, grphcs: ['bubble.gif']});
Code:
leaves = new rise_fall({speed: 60, sway: 20, Amount: 36, grphcs: (function(){
var gb = 'leafimages/Leaf', ge = '.png', i = 12, ga = [];
while(--i){ga.push(gb + i + ge);}
return ga;
})(), accumulate: 100});
Bookmarks