Mootools 1.2.5 Element.setStyle / Morph

发布于 2024-10-06 08:20:04 字数 567 浏览 3 评论 0原文

我最近为我的网站制作了 Mootols 脚本。使用 Fx.Morph,我成功地创建了我想要的效果。然而,该脚本在 Internet Explorer 7 和 8 中失败(在 9 中工作正常,没有费心检查 IE6)。我正在使用 mootools 1.2.5。

挖掘问题,我可以弄清楚以下

  • 所有问题都来自 Fx.Morph,他使用无效值调用 setStyle
  • 不知何故,当将元素的高度从 0px 变形到 160px 时,使用负值调用 setStyle(例如-3px) <---- 这是 IE 抛出错误的地方

现在,我通过在 Mootools 核心的 setStyle 函数中执行以下操作来“修补”该错误:

if((Browser.Engine.trident && value[0] == '-' && (property == 'height' || property == 'width')) || value[0] == 'N')
    value='0px';

任何人都有关于此问题的更多信息或经历过类似的情况问题?

I recently made a Mootols script for my website. Using Fx.Morph, I succesfully created the effects I was aiming for. However, the script fails in Internet Explorer 7 and 8 (works fine in 9, didn't not bother to check IE6). I am using mootools 1.2.5.

Digging up the problem, I could figure out the following

  • All my problems are coming from Fx.Morph, who calls setStyle with invalid values
  • Somehow, while morphing height of an element from 0px to 160px, setStyle is called with a negative value (such as -3px) <---- this is where IE throws an error

For now, I "patched" the error by doing the following in the setStyle function of the Mootools core:

if((Browser.Engine.trident && value[0] == '-' && (property == 'height' || property == 'width')) || value[0] == 'N')
    value='0px';

Anyone has some more info on this issue or experienced a similar problem?

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

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

发布评论

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

评论(1

隐诗 2024-10-13 08:20:04

看起来 Morph 并不关心它是否要使用无效的属性/值组合调用 setStyle,并且 setStyle 也不关心它是否要为指定的属性设置无效值。

考虑到这一点,我的问题来自于我使用的效果。我使用了类似“Bounce.easeIn”的元素,该元素必须将高度从 0px 变形到 160px。然后 Morph 将调用带有负值的 setStyle。

就我而言,将效果设置为“线性”使其按预期工作。

在我看来,Morph 应该“意识到”它要做什么,并防止使用无效值调用 setStyle。当使用不可能的属性/值调用 Element.setStyle 时,Element.setStyle 也应该抛出错误,而不是让浏览器崩溃/处理问题。我会看看这个问题是否已在 1.3 中修复,如果没有修复,请开票。

It seems like Morph doesn't care if it is about to call setStyle with invalid property/value combo and setStyle doesn't either care if it is about to set an invalid value for a specified property.

With this in mind, my problem came from the effect I was using. I was using something like "Bounce.easeIn" with an element that had to morph height from 0px to 160px. Morph would then call setStyle with negative values.

In my case, setting the effect to "linear" made it works like expected.

In my opinion, Morph should be "aware" of what it is about to do and prevent calling setStyle with invalid values. Element.setStyle should also throw an error when he is called with impossible property / value instead of letting browser crash/handle the problem. I'll see if this has been fixed in 1.3 and open a ticket if not.

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