过早停止 jQuery 动画
我正在尝试使用 JQuery 淡入和淡出透明 png。当然,它在 Firefox 中看起来很流畅,但在 IE(7 和 8)中明显不太可接受。这是 IE 的一个已知错误,不幸的是似乎没有太多的解决方法。
基本上我正在做的就是在图像上放置一个半透明的白色矩形,使图像出现在“背景中”。我想顺利地做到这一点,这就是 fadeIn 的用武之地。然而,由于 IE 错误,我被迫在图像上淡入一个完全不透明的白色矩形,不幸的是它消失了。虽然这看起来明显更好并且几乎是我正在寻找的,但它仍然是不可接受的。用户需要能够在页面上看到一些图像,尽管是在背景中。
所以我的问题是这样的:
有没有办法在动画达到预期动画时间的 75% 后停止 fadeIn 函数(或任何 jquery 动画,真的)?
这将使我的图像 75% 混合白色矩形,而且我不必处理 IE 令人讨厌的透明 png 错误。
谢谢!
I'm trying to fadeIn and fadeOut a transparent png using JQuery. Of course, it looks slick in Firefox, but significantly less than acceptable in IE (7 and 8). It's a known bug with IE, and unfortunately there doesn't seem to be much of a workaround.
Basically what I'm doing is place a semi-transparent white rectangle over an image to make the image appear 'in the background'. I want to do this smoothly, and that's where fadeIn comes in. Because of the IE bug, however, I've been forced to fadeIn a completely opaque white rectangle over the image instead, making it unfortunately disappear. While this looks significantly better and is ALMOST what I'm looking for, it's still not acceptable. The user needs to be able to see SOME image on the page, albeit in the background.
So my question is this:
Is there a way to stop the fadeIn function (or any jquery animation, really) after animating for 75% of its expected animation time?
This would leave my image 75% mixed the white rectangle, and I wouldn't have to deal with IE's nasty transparent png bug.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用不透明图像并将其不透明度设置为 75%。
You could use an opaque image and just animate it's opacity to 75%.
使用 animate 函数将不透明度属性设置为您想要的级别,而不是 fadeIn/fadeOut。
Instead of fadeIn/fadeOut, use the animate function to animate the opacity property to your desired level.
您还可以使用 fadeTo 函数。
这是合成:
You can also use the fadeTo function.
This is the synthax:
不推荐适合您的情况,但这是您所问问题的实际答案:-)
http://api.jquery.com/stop/
Not recommended for your situation, but here's the actual answer to your question as asked :-)
http://api.jquery.com/stop/