如何在本机绘制之前拦截 Google Chrome 的 resize() 事件?
在您更改某些页面元素的位置以响应 resize()
事件的情况下(例如,模拟 min-width
类型的情况), Firefox 在重新绘制窗口之前会耐心等待事件处理程序完成。另一方面,Chrome 首先绘制,然后处理事件处理程序,然后在必要时重新绘制。
在 Chrome 中,结果是明显的“弹跳”或闪烁,因为要重新定位的元素首先在其新位置绘制(基于其原始位置+/-新窗口尺寸),然后在其重新计算的位置重绘(基于您的事件处理程序的说明)。
我需要一种方法来提前获取事件处理程序,或者强制 Chrome 在我告诉它之前不重新绘制。
请注意,这不是去抖/节流问题。事实上,这会让这个问题更加引人注目!
In situations where you are changing the position of some on-page element in response to a resize()
event (for example, to emulate a min-width
type situation), Firefox patiently waits for your event handler to complete before repainting the window. Chrome, on the other hand, paints first, then processes your event handler, then re-paints if it has to.
In Chrome the result is a significant "bounce" or flicker as the element being repositioned is first drawn at its new location (based on its original location +/- the new window dimensions) and then redrawn at its re-calculated location (based on your event handler's instructions).
I need a way to either get my event handler in earlier, or force Chrome to not re-paint until I tell it to.
Note that this is not a debounce/throttle issue. That would, in fact, make this issue even more noticeable!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论