I'm trying to figure out how to pass in settings to an animation plugin in the following format (I know it's bad to expect users to jump in and play with settings like this, but I'll be building a GUI to go alongside it as well):
$('#animationContainer').plugin({
'path':[
{'path_on_x':[ // PATH_ON X IS AN ARRAY
{'0':'0px','1':'0px','2':'0px'}, // object 1 starting X values (0,1,2)
{'0':'0px','1':'0px','2':'0px'}, // object 2 starting X values (0,1,2)
{'0':'150px','1':'150px','2':'150px'} // object 3 starting X values...
]},
{'path_off_x':[ // PATH_ON X IS AN ARRAY
{'0':'0px','1':'0px','2':'0px'},
{'0':'0px','1':'0px','2':'0px'},
{'0':'150px','1':'150px','2':'150px'}
]},
{'path_on_y':[ // PATH_ON Y IS AN ARRAY
{'0':'0px','1':'0px','2':'0px'},
{'0':'0px','1':'0px','2':'0px'},
{'0':'0px','1':'50px','2':'200px'}
]},
{'path_off_y':[ // PATH_ON Y IS AN ARRAY
{'0':'0px','1':'0px','2':'0px'},
{'0':'0px','1':'0px','2':'0px'},
{'0':'200px','1':'50px','2':'0px'}
]}
]
});
This code is currently setup within the plugin and I'm referencing all of the static values. "PATH" contains all of the settings related to animating the object along a path. The path_on_x, path_off_x, path_on_y and path_off_y all contain specific sets of coordinate values for animating from point 0 to point 1 to point 2, etc.
Each set of coordinates inside the arrays contain values specific to different objects being animated. (NOTED in CODE ABOVE)
I'm used to doing the typical defaults= .... code and just merging that with the user options, but how would I go about setting up defaults (or some other kind of fallback setting) in this case? I'm pretty sure the standard defaults = ... code isn't going to cut it, and simply using the above code in place of the defaults doesn't account for the fact that there may be 20 objects being animated instead of 3 shown above.
Any suggestions? Thanks!