DarioSantarelli.Blog("UgiDotNet");

<sharing mode=”On” users=”*” />
posts - 176, comments - 105, trackbacks - 3

My Links

News


This is my personal blog. These postings are provided "AS IS" with no warranties, and confer no rights.




Tag Cloud

Archives

Post Categories

My English Blog

jQuery Color Animations

Promemoria: per far funzionare correttamente le "animazioni colorate" utilizzando versioni di jQuery successive alla 1.2 tramite la function animate, ad esempio:

$('#MyBox').animate( {backgroundColor: "#c6c6c6"} , 750 );

è consigliabile utilizzare il plugin Color Animation.
Dietro le quinte il plugin effettua un override del comportamento di animazione per tutte le possibili proprietà che supportano la colorazione.
Ecco un interessante estratto del codice del plugin (in rosso le proprietà CamelCase che possiamo eventualmente utilizzare) :

(function(jQuery)
{
   // We override the animation for all of these color styles
   jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor',
                'borderRightColor','borderTopColor', 'color', 'outlineColor'
],
                 function(i,attr)
                 {
                    jQuery.fx.step[attr] = function(fx)
                                           {
                                             if (fx.state == 0) 
                                             {
                                               fx.start = getColor( fx.elem, attr );
                                               fx.end = getRGB( fx.end );
                                             }
                                             fx.elem.style[attr] = "rgb(" + [
Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
                                                                            ].join(",") + ")";
                                           }
                 });
...

})(jQuery);


Spero possa essere utile.

Technorati Tag:

Print | posted on mercoledì 29 ottobre 2008 20:36 |

Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET