简体   繁体   English

可以轻松地动画.classB样式的.classA样式吗?

[英]can a .classA styles to .classB styles be animated easly?

Is there a way to animate in Jquery without specifying every property? 有没有办法在Jquery中制作动画而不指定每个属性?

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.. 如果没有,最好的方法是什么..

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 你可以用jQueryUI / switchClass来做 ,你只需要一个自定义构建的jQueryUI,启用了Effects Core - 没有别的,大约是11k缩小了

Example

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM