[英]Animate scaleX/scaleY
jQuery does not provide a scaleX/scaleY transition effect – is there a solution (plugin) to do this? jQuery不提供scaleX / scaleY过渡效果 –是否有解决方案(插件)来做到这一点?
I'm thinking of this example: 我在想这个例子:
image copyright: (c) 2011 Microsoft, http://msdn.microsoft.com/en-us/library/ms742560.aspx 图片版权:(c)2011 Microsoft, http://msdn.microsoft.com/en-us/library/ms742560.aspx
jQuery UI does offer that. jQuery UI确实提供了这一点。 Refer to http://docs.jquery.com/UI/Effects/Scale
请参阅http://docs.jquery.com/UI/Effects/Scale
I found a good way of achieving this using CSS transitions. 我找到了使用CSS转换实现此目标的好方法。 Add the "Ease" transitions on your element and then when you want to animate it, use jQuery's addClass to add a new class which contains the scale factor.
在元素上添加“缓动”过渡,然后在要为其设置动画时,使用jQuery的addClass添加一个包含比例因子的新类。
The CSS: CSS:
.obj{
width: 100px;
height: 100px;
background: grey;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
.scale{
-webkit-transform: scaleX(0.5);
-o-transform: scaleX(0.5);
-moz-transform: scaleX(0.5);
transform: scaleX(0.5);
}
The jQuery: jQuery:
$("#a_b").click(function(){
$(".obj").addClass("scale");
});
jQuery provides width/height transition effect. jQuery提供了宽度/高度过渡效果。 Can't you use that?
你不能用那个吗?
You could also use a timer (setInterval) and make your own animation. 您还可以使用计时器(setInterval)并制作自己的动画。 You split the scale amount into a number of frames and you scale it frame by frame.
您将缩放比例数量分成多个帧,然后逐帧缩放。 You could also use some easing functions to make the animation more interesting.
您还可以使用一些缓动功能使动画更有趣。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.