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';

有人有更多关于这个问题的信息或遇到过类似的问题吗?

4

1 回答 1

0

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.

于 2010-12-08T17:43:52.923 回答