I have been experimenting with jQuery a lot recently and have found
that sometimes when working with a lot of elements in certain browsers
under certain circumstances the animation can be choppy and/or slow.
I therefore decided that it would be a good idea to implement a
setting the user could toggle to turn fancy animation effects on and
off according to his choice.

I have an idea for doing it involving object prototypes, but I need to
know if what I have in mind is possible before I start.

At the moment I have a javascript object that I wrote that includes a
method that performs all the animation effects.  What I have in mind
is to replace it with a function that just changes the CSS of elements
directly and relocate the animation function outside the object
itself.  I would then have a checkbox in a form, or a cookie or some
other token the script can check for.  If it is set then I do the
following:

myObject.prototype.animate = myCustomAnimationFunction;

If I am using a checkbox then the user will be able to toggle the
animation effect on and off without reloading the page.  In this case
I need to undo the prototype function overwrite.  Is this possible?

I know it would be possible to simply include a basic and a full
animation method inside the object itself, but having the fancy
animation function outside the object has other advantages,
particularally regarding maintainability of code.  My manager would
like to be able to deploy the same code across several sites but with
different animation styles on each one.  An external function would
mean I could put it in a seperate file and just use a different file
in each site.

Reply via email to