I have an app that opens embedded tweets in a popup modal dialog. The problem I’ve encountered: in order to center the dialog vertically, I need to get its dimensions AFTER the embedded tweet is rendered.
The callback function provided by twttr.widgets.createTweet() is supposed to fire after the tweet is fully rendered, but I’ve found that it’s firing too early – before the iframe element’s width and height have been set, so the popup dialog is not correctly centered. However, if I set a 250ms timeout, and THEN get the iframe’s size, it’s set correctly and the centering routine is happy.
A quarter of a second timeout isn’t unbearable, but it would be much better if the completion callback could happen after all rendering is finished instead of in a halfway state. Timeouts are fragile.