can a .classA styles to .classB styles be animated easly?

喜欢而已 提交于 2020-02-02 06:25:06

问题


Is there a way to animate in Jquery without specifying every property?

Lets, say:

.classA{
   color:red;
}
.classB{
   color:blue;
}

function animate(selector,classA,classB,time){
    styles1 = $(classA).invented_get_styles();
    styles2 = $(classB).invented_get_styles();
    $(selector).animate(styles1,styles2,time);
}

Almost alll this syntax is invented but i think that what i am asking can be understood,

Is posible to animate from classes retrieving the styles (automated) and apply them instead of knowing (manual) the values? or if not, what's the best way..


回答1:


You can do it with jQueryUI/switchClass, you only need a custom build of jQueryUI with Effects Core enabled - nothing else, which is about 11k minified

Example

$( ".element_to_be_animated" ).switchClass( "oldClass", "newClass", 1000 );


来源:https://stackoverflow.com/questions/8023575/can-a-classa-styles-to-classb-styles-be-animated-easly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!