If a similar problem ( offsetWidth was 0 because the item has not been displayed yet). I made simple:
setTimeout(function() { ... do stuff that needed final width of object ... }, 0)
And that seems to work flawlessly in my business. This basically asks to be called when the current javascript column is empty.
I assume that if you create a DOM element in javascript and its width is defined in external CSS as "100%", the offsetWidth (and offsetHeight ) of this object will not be calculated before all javascript has finished working.
Using setTimeout(callback, 0) , it seems to be called after the browser completes the current javascript call. And took the time to apply all the CSS to the new DOM elements.
vaab
source share