我有两个问题:
1。如何在点击时同时动画jQuery多次转换(例如scale()+ rotate())?
(我尝试使用step
函数,如下所示:
$("target").animate({'left':'100px',myScaleProperty: 2, myRotationPreperty: 180}, {step: function(now,tween) {
if (tween.prop == myScaleProperty) {
$(this).css({'transform','scale('+now+')'})
}
if (tween.prop == myRotationProperty){
$(this).css({'transform','rotate('+now+'deg)'})
}
},duration:'slow','linear'})
2。如何在jQuery上制作可逆动画(不定义另一个反向动画功能)?
答案 0 :(得分:2)
我的博文显示了如何同时缩放和旋转
http://bcksp.blogspot.com/2011/12/css3-based-animation-instead-of-jquery.html
这里是小提琴
http://jsfiddle.net/alsadi/sFzSR/
拥有这样的css你可以使用jquery来添加动画类或删除它
transform:rotate(180deg) scale(0.5);
在jquery javascript中它可能看起来像这样
$(this).css({transform:'rotate(180deg) scale(0.5)'})
UPDATE:用单个基于触发的变换替换无限过渡动画循环