在调整容器 DIV 大小期间隐藏 iframe 会加快响应速度吗?
各位,
我有一个包含许多 IFrame 的 DIV(长话短说)。用户可以调整 DIV 的大小,iFrame 的大小也会随之改变。然而,调整大小的过程缓慢且不稳定,大小会“突发”变化。
在调整大小期间隐藏 iFrame 会加快速度吗?
是否有暂时隐藏 iFrame 的最佳实践?我似乎记得其他地方的人推荐了一些有点奇特的方法来隐藏它们,尽管我不记得为什么。
谢谢, 安·L。
Folks,
I have a DIV that contains a number of IFrames (long story). The DIV can be resized by the user, and the iFrames change size along with it. However, the resizing process is slow and choppy, with the size changing in "bursts".
Would hiding the iFrames during the resize speed this up?
Is there a best practice for temporarily hiding an iFrame? I seem to remember people elsewhere recommending slightly exotic methods for hiding them, although I don't recall why.
Thanks,
Ann L.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
另一种选择是显示要应用调整大小的区域的“边界框”或“预览”。类似于 在此处调整示例大小时看到的虚线边框
Another option would be to show a 'bounding box' or 'preview' of the area in which you are applying the resize. Similar to The dotted border you see when re sizing the example here
解决此问题的一种方法是不在调整大小事件上执行实际的调整大小(这会导致不稳定,因为它经常被调用),而是在调整大小时设置一个计时器,并且仅在窗口发生时才执行实际的调整大小大小有一两秒没有改变。然后,用户可以自由调整窗口的大小,当他们暂停时,它会在没有任何中间不稳定的情况下布置内部。一般来说,它的工作原理如下:
One way to solve this problem is to not carry out the actual resize on the resize event (which leads to the choppiness because it gets called so often), but rather to set a timer on the resize and only do the actual resize when the window size hasn't changed for a second or two. Then, the user can freely resize the window and when they pause, it lays out the interior without any of the intermediate choppiness. In general, it works like this:
屏幕上的内容越少,回流速度越快。如果您可以隐藏元素,直到复杂的 DOM 更改完成,您将在最后强制进行额外的重绘,但中间步骤应该更快。
The less there is on the screen, the faster the reflow. If you can hide elements until a complex DOM change is complete you'll force an additional redraw at the end, but the intermediate steps should be faster.