使用 jQuery 实现非常流畅的动画效果
我在页面上设置了一些 jQuery,以便在用户单击链接时交换一些 DIV。 DIV 内部有 Flash 对象、段落和图像,当我单击链接将其交换出来时,效果并不完全...平滑。
这是我的代码:
$('#div').toggle('fast');
$('#anotherdiv').toggle('fast');
它有点卡在闪存对象上一小会儿,然后完全消失。有谁知道一个可以在 jQuery 中制作非常流畅的动画效果的插件吗?我看了一下 jQuery UI,但它对于我想要的功能来说似乎有点过分了。
干杯。 :)
I have some jQuery set up on my page to swap out some DIVs when a user clicks a link. The DIVs have flash objects, paragraphs and images inside them and when I click the link to swap it out the effects aren't exactly... smooth.
This is my code:
$('#div').toggle('fast');
$('#anotherdiv').toggle('fast');
It kinda gets stuck on the flash object for a short while and then disappears completely. Does anyone know a plugin to make really smooth animated effects in jQuery? I took a look at jQuery UI but it seems a little overkill for what I want it for.
Cheers. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这里的速度问题主要与Flash有关……您要求浏览器快速重新绘制视频,而不是浏览器擅长做的事情。我会考虑在隐藏之前隐藏 Flash 元素,并在其余部分之后显示它们,如下所示:
The speed problem here is mainly with flash...you're asking the browser to rapidly repaint a video, not something a browsers all that great at doing. I would consider hiding the flash elements before hiding, and show them after the rest, something like this:
JavaScript 动画确实依赖于浏览器。 IE 在 JavaScript 方面非常慢,很多时候甚至不值得尝试使用 IE 制作动画。 Firefox 和 Chrome 好多了。在chrome中尝试一下,看看是否还有问题。
Javascript animation is really dependant on the browser. IE is terribly slow at javascript and a lot of the time it isn't even worth trying to animate with IE. Firefox and chrome are much better. Try it in chrome and see if it is still problematic.
@stimms 关于速度的说法是正确的,但总有一个解决方法:)
我会在开始动画之前隐藏 Flash 容器。这样就不会妨碍事情的发展。
@stimms is right about speed but there's always a workaround :)
I'd hide the flash container before starting the animation. That way it won't be in the way of things.
确保对象的
wmode
和/或 Flash 的嵌入标签设置为transparent
或opaque
...值得一试:)
Make sure the
wmode
of the object and/or embed tag of the flash are set totransparent
oropaque
...it is worth a shot :)