当回流导致元素改变大小时如何收到通知

发布于 2025-01-03 01:50:32 字数 270 浏览 4 评论 0原文

我们的网站使用 Websocket,因此它已经需要最新型号的浏览器。鉴于此,当元素调整大小时如何通知我?我们可能有 canvas 和 svg 子元素,需要调整大小以响应父 DOM 元素的大小调整。

优雅的方法是挂钩“onresize”,但遗憾的是,它不会在元素上调用(至少在 Chrome 18 中不会)。宁愿不提供定期触发计时器来测试元素大小变化的答案。

另外,请理解,回流可能不是由窗口或正文调整大小引起的,所以请不要去那里。

任何精彩、简单、优雅的想法都会受到极大的赞赏。

Our site uses Websocket, so it already requires late-model browsers. Given that, how can I be notified when an element resizes? We may have canvas and svg child elements that need to resize in response to the parent DOM element resizing.

Elegant method would be to hook 'onresize' but, alas, it does not get called on elements (at least not in Chrome 18). Would prefer to not be offered an answer to periodically fire a timer to test for a change in element size.

Also, please understand that the reflow may not be caused by the window or body being resized, so please don't go there.

Any brilliant, simple, elegant ideas would be hugely appreciated.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文