好吧,经过一番挖掘,我找到了一个(最多是破解的)解决方案。不幸的是,它实际上涉及修改 jQuery UI。请注意,我尚未对此结果进行彻底分析来确定性能(以及可能的其他指标)的影响。但无论如何,为了让它发挥作用,有几个地方需要改变。请注意,所有这些更改都发生在 UI 鼠标小部件的事件内。当小部件绑定 mousemove 和 mouseup 事件时,第一个更改发生在 _mouseDown 事件中。改变:
$(document)
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
To:
$($(this.element).get(0).ownerDocument)
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
因此,这基本上将这些事件绑定到所有者文档,无论所有者文档是常规的旧 HTML 页面还是 iframe 中的页面。其次,当用户松开鼠标时,我们需要解除这些事件的绑定。在 UI Mouse 小部件的 _mouseUp 事件中,更改:
$(document)
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
To:
$($(this.element).get(0).ownerDocument)
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
只需解除我们上面绑定的事件的绑定即可。最后,我们需要返回 _mouseDown 事件并进行最后的更改。在此函数的顶部,请注意以下行:
// don't let more than one widget handle mouseStart
if(mouseHandled) {return};
我们需要将其注释掉或删除。任意一个。之后,我们似乎可以在 iframe 内部和外部调整大小。无论这是否会破坏任何其他小部件或插件,我不知道。但我们希望不会。如果你们能够就这一潜在影响提供一些建议,并希望提供一个更优雅的解决方案,我将不胜感激。谢谢。