I am trying to convert a library of mine into a web component and I have run into a problem with when to tell the component has been laid out.
Web Components have a callback called connectedCallback which looks like it might be what I need, but when inspecting self in the callback, my offset dimensions are both zero:
connectedCallback() {
console.log(this.offsetWidth, this.offsetHeight);
}
When I queue up the dimensions query, the dimensions are there, so sometime between the web component connecting and the event queue reaching the next item, the web component gets laid out by the browser engine, gaining correct dimension values:
connectedCallback() {
setTimeout(() => console.log(this.offsetWidth, this.offsetHeight), 0);
}
I am wondering if there is a callback to tell when the layout event has happened?