JQuery 颜色动画无法可靠触发

发布于 2024-08-03 21:29:33 字数 1040 浏览 6 评论 0原文

我在使用 jquery 悬停事件时遇到问题。我已经减少了这个问题。您可以在此处找到工作演示。我可以在 IE、FF、Opera 和 Chrome 中移动鼠标后重现这一点。

我在鼠标悬停事件中使用排队动画。大约 1% 的情况下,当鼠标离开 td 后,td 元素的颜色仍保留为 #0f0。这不应该是这样。 mouseout 事件应保证在一段时间过后,所有 td 最终都会返回到 #00f

更新2:

我现在已经尽可能地减少了这个可能。根本没有使用鼠标事件。它开始在 Opera 中工作得更好,但现在 IE 是一个完整的集群。

无论如何,我使用一个按钮来触发此操作:

function ani() {
    $('td')
        .stop()
        .animate({backgroundColor: '#0f0'}, 3000)
        .animate({backgroundColor: '#00f'}, 3000);
}

请参阅此处

更新[n + 1]:

我不能不管这个。我已经确定动画确实正在发生。它只是没有自动设置背景颜色。我通过添加文本并同时对背景和前景进行动画处理来完成此操作。在正常情况下,一旦开始动画,您就永远不会看到文本,但有时背景会被“遗忘”,有时前景也会被“遗忘”。这向我表明,jquery 动画实际上正在发生,但它只是没有对指示的所有属性进行动画处理。对于好奇的人,请在此处查看其实际情况。 (警告:IE 对此感到非常窒息)

好吧,现在去玩一些视频游戏。

I'm having a problem using the jquery hover events. I've created a reduction of the problem. You can find a working demonstration here. I can reproduce this after moving the mouse around in IE, FF, Opera, and Chrome.

I'm using queued animations in my mouseover event. Roughly 1% of the time, the color of the td elements is left as #0f0 after the mouse has left the td though. This should not be. The mouseout event should guarantee that eventually all tds turn back to #00f after a time has passed.

Update 2:

I've now reduced this probably about as far as it will go. No mouse events used at all. It's started working better in Opera, but now IE is a total cluster.

Anyway, I'm using a button to trigger this:

function ani() {
    $('td')
        .stop()
        .animate({backgroundColor: '#0f0'}, 3000)
        .animate({backgroundColor: '#00f'}, 3000);
}

See it here.

Update [n + 1]:

I just can't leave this alone. I've determined that the animation actually is occurring. It's just not automating the background color. I've done this by adding text and animating the background and foreground in unison. Under normal conditions, you should never see the text once it starts animating, but sometimes the background gets "forgotten", and sometimes the foreground. This indicates to me, that a jquery animation is actually occurring, but it is just not animating all the attributes it was instructed to. For the curious, see it in action here. (warning: IE chokes pretty hard on this)

Ok, going to play some video games now.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

久伴你 2024-08-10 21:29:33

我不明白你的1%这个数字是怎么得出的。我不确定您所看到的行为,但在 FF3 和 IE8 中,我都会遇到这个丑陋的非法属性值错误,如下所示:

修复 jquery.color.js 中的该行,FF3 和 IE8 都可以正常工作,尽管 IE8 会白屏,但它最终会恢复。

jQuery 非常适合管理 DOM,但不太适合效果。根据我的经验,UI 的东西使用起来很痛苦,并且总是存在问题。不过,框架本身一直对我很好。

I don't understand how you get your 1% figure. I'm not sure about what behavior you're seeing, but in both FF3 and IE8 I get this ugly illegal-property-value error as documented here: http://dev.jqueryui.com/ticket/4251. More relevantly, a good dozen of them aren't changing colors, even if changed to simply a single-color animate.

Fixing that line in the jquery.color.js and both FF3 and IE8 work like a charm, although IE8 white-screens, it recovers eventually.

jQuery is great for managing the DOM, not so great for effects. In my experience, the UI stuff is painful to use and has always had issues. The framework itself, though, has always treated me well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文