Embedded tweets completion event?

2019-04-08 18:55发布

Using Twitter's embed code for single tweets causes a script called widget.js to be loaded. This script is responsible for dynamically generating the HTML of the tweet.

Is there an event triggered by widget.js when the rendering of an embedded tweet is complete? How can my code find out that rendering is complete?

I need this because I am trying to use jQuery Masonry to layout a set of tweets. Masonry fixes the container height for each tweet before the tweets are fully rendered, causing overlap. I'd like to be notified that all tweets are fully rendered in order to refresh the Masonry layout.

2条回答
该账号已被封号
2楼-- · 2019-04-08 19:40

I ended up using a jQuery "watch" plugin (e.g. https://github.com/darcyclarke/jQuery-Watch-Plugin) to watch for DOM changes on the container div.

查看更多
来,给爷笑一个
3楼-- · 2019-04-08 19:48

If you look into the uncompressed code here searching for "render" yields this interesting conditional

    if (this._rendered) {
        var anchor = this.byClass('twtr-join-conv', 'a');
        anchor.href = 'http://twitter.com/' + this._getWidgetPath();
    }

and somewhat lower in the code is

    this._rendered = true;
    // call the ready handler
    this._ready();
    return this;

you might be able to explore...

查看更多
登录 后发表回答