用animate实现jQuery的震动效果 [英] Implementing jQuery's shake effect with animate

查看:220
本文介绍了用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.

另一种思考方法:如果你使用多种效果,我建议< a href =http://jqueryui.com/download =noreferrer>只下载你想要的效果的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.

这篇关于用animate实现jQuery的震动效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆