简体   繁体   English

jQuery水平手风琴抖动

[英]jQuery Horizontal Accordion Jitter

I know this is a fairly popular topic around here, but I'm hoping someone can help me with my particular implementation. 我知道这是一个很受欢迎的话题,但是我希望有人可以帮助我完成特定的实现。 I'm working on a design that uses jQuery animations to create an accordion menu, and it works, but I get a lot of jitter during the animation. 我正在设计一个使用jQuery动画来创建手风琴菜单的设计,它可以工作,但是在动画过程中会产生很多抖动。

From my searching, the solution for this seems to be to animate all of the elements with one animate() object and a step() function to ensure synchronization. 通过我的搜索,解决方案似乎是使用一个animate()对象和一个step()函数为所有元素animate() ,以确保同步。 The problem is, I can't for the life of me, come up with a step() function that works. 问题是,我无法终生,想出一个有效的step()函数。

Here is my latest attempt: http://www.3strandsmarketing.com/jq-test-v2.html 这是我最近的尝试: http : //www.3strandsmarketing.com/jq-test-v2.html

It works if you move your mouse slowly, but the code is kludgy to say the least, and if you move your mouse quickly it totally falls apart (btw, I've tried mitigating this with the hoverIntent plugin, but I didn't like the lag it added). 如果您缓慢移动鼠标,它会起作用,但是至少可以说代码很笨拙;如果快速移动鼠标,它会完全崩溃(顺便说一句,我曾尝试使用hoverIntent插件缓解这种情况,但我不喜欢滞后时间)。

I think the answer maybe in JQuery Accordion Jitter Issue or Jitter in Jquery Accordion Implementation , but I lack the skill to adapt their code to my situation. 我认为答案可能在JQuery Accordion Jitter IssueJquery Accordion Implementation中的Jitter中 ,但是我缺乏使他们的代码适应我的情况的技能。

Also I really want to avoid the extra weight of adding jQuery UI if at all possible. 另外,我真的想尽可能避免添加jQuery UI的额外负担。 Any help is greatly appreciate. 任何帮助,我们将不胜感激。 Thanks. 谢谢。

Well, after several hours of tinkering, it's now 5am and I think I have it. 好了,经过几个小时的修补,现在是凌晨5点,我想我已经掌握了。 I was eventually able to adapt the solution I referenced in my original question. 我最终能够适应在原始问题中引用的解决方案。 I updated the jsfiddle that @rwilliams made with the new code, so if you're interested, you can see my adaptation there ( http://jsfiddle.net/bKZ4t/2/ ). 我更新了@rwilliams用新代码制作的jsfiddle,因此,如果您有兴趣,可以在那儿看到我的改编( http://jsfiddle.net/bKZ4t/2/ )。

It works pretty well. 效果很好。 Sadly though, the jitter is not completely gone. 但是,令人遗憾的是,抖动并没有完全消失。 It is much less noticeable than it used to be though, and I think I'll just have to settle for that unless someone else can improve my implementation. 它远没有以前那么引人注目,我认为,除非其他人可以改进我的实现,否则我将不得不解决这个问题。

Thanks to all who contributed. 感谢所有贡献者。

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

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