用animate实现jQuery的震动效果
我已经获得了jQuery lib的缩减子集我缺少的一个关键功能是 .effect
函数。但我有 .animate
。我想知道是否有人会有任何关于如何重现动画功能的想法。
I've been given a cut down subset of the jQuery lib one of the key features I'm missing is the .effect
functions. I do however have .animate
. I was wondering if anyone would have any ideas how I could go about reproducing the animation functions.
我特别想知道我需要保留几行代码大小下降。这就是为什么jquery lib尽可能小,并且没有效果函数。
I am particularly consious of making this only a few lines as I need to keep the code size down. Which is why the jquery lib is as small as it is and doesnt have the effects functions.
TLDR - 我正在尝试替换
TLDR - I'm trying to replace
$("#"+id_string).effect( "shake", {}, "fast" );
在jQuery中使用 .animate
。
With something using .animate
within jQuery.
它实际上已经以这种方式实现了,您可以在 jquery.effects.shake.js
,如果你只想复制那种功能。
It's actually already implemented this way under the covers, you can see exactly how in jquery.effects.shake.js
, if you wanted to copy only that functionality you can.
另一种思考方法:如果你使用多种效果,我建议只下载你想要的效果的jQuery UI 。为此,在不自行复制功能的情况下,您只需 jquery.effects.core.js
和 jquery.effects.shake.js
。
Another approach to think about: if you're using multiple effects, I'd recommend downloading jQuery UI with only the effects you want. For this effect, without copying the functionality yourself, you would just need jquery.effects.core.js
and jquery.effects.shake.js
.