Another input method to .css? A note on .animate and things like borderWidth borderColor

Another input method to .css? A note on .animate and things like borderWidth borderColor


I don't know if anyone thought of it, but how about adding another
method of calling .css?
In my own framework I allow a call such as:
pf('#foo').css(['backgroundColor', 'color', 'borderLeftColor']);
And the call will output an object with that information (keys as the
style keys, and the values of those are the current css values.
It's actually fairly useful, as you can use it to generate an object
containing current css information, then use that to revert styles back
after you've changed something.
Also a small note on the jquery.color plugin. Has anyone thought of
supporting borderColor in it? I know the individual edges are supported,
but it would be nice if it supported the generic css property to animate
all 4 sides at once without specifying them individually.
It's actually fairly easy to do, just take this method:
jQuery.fx.step[attr] = function(fx){
if ( fx.state == 0 ) {
fx.start = getColor( fx.elem, attr );
copy the function and turn it into a generic below:
function step(fx, attr){
.....
Then turn the old one into a call like:
jQuery.fx.step[attr] = function(fx){
step(fx, attr);
}
After that one simple addition:
jQuery.fx.step.borderColor = function(fx) {
step(fx, 'borderTopColor');
step(fx, 'borderRightColor');
step(fx, 'borderBottomColor');
step(fx, 'borderLeftColor');
};
Of course, I have a feeling that someone actually adding it could easily
create a better performing one that actually handles .borderColor
separately by grabbing the actual borderColor (rather than individually
animating the four corners) and splitting the value up.
--
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://nadir-seen-fire.com]
-Nadir-Point (http://nadir-point.com)
-Wiki-Tools (http://wiki-tools.com)
-MonkeyScript (http://monkeyscript.nadir-point.com)
-Animepedia (http://anime.wikia.com)
-Narutopedia (http://naruto.wikia.com)
-Soul Eater Wiki (http://souleater.wikia.com)