CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 38
Consider using ResizeObserverΒ #618
Description
Enhancement/Discussion
We might want to consider using a ResizeObserver
polyfill to allow the Dimensions
meta manager to perform better, allowing it to detect changes to DOM elements that change the size information of a DOM element.
The draft spec is available at WICG ResizeObserver Draft. A well thought out polyfill is available at que-etc/resize-observer-polyfill which uses MutationObservers and Mutation Events to provide spec compliant functionality with some minor limitations.
It is currently available natively in Chrome/Opera under a flag.
Right now, every time a widget is re-rendered, any nodes that are registered with the Dimensions meta manager will have their bounding rectangle re-calculated, whether it has actually been changed. This would allow the manager to be more reactive and keep a cache of size information, of which its observed DOM elements would have their values updated on actual resize.
Because the polyfill is designed to deliver the resize changes only when it is convinced it has the right information, there could be an issue where the queuing of changes get delivered after the DOM has be re-rendered after an invalidation, either causing a double invalidation or incorrect information being offered up to the widgets. This would require investigation to help ensure that it operates effectively.