JabbR/JabbR — pull request #1197 by BrianRosamilia (2014-08-21 14:19:21+00:00)
Title: Optimal twitter scrollToBottom using twitter 'rendered' event

Problem : Chatting a link (that will be embedded as a tweet) doesn't work properly; even if you are scrolled to the bottom of the chat, a tweet can easily cause you to stop seeing the latest messages. This also forces you to scroll to see all subsequent messages.

Here's what happens in an empty chat even with just a single tweet posted in chrome.

![Scroll To Bottom Issue](http://i.imgur.com/B2dcKR4.png)

Cause : Embedded tweets are loading a dynamic script and, in the current Chat.twitter.js, it tries to scroll to the bottom prior to letting the tweet fully render. Larger tweets (images,videos) seem to exacerbate this problem.

Solution : Binding the (poorly documented) 'rendered' event from the dynamic twttr object allows you to get the exact size of the tweet that's being embedded. You can use that to determine whether or not to scroll to the bottom. It will consistently keep your chat flowing downward as new tweets are posted when you're scrolled to the bottom.

Concerns : Still needs a magic constant just like the $.fn.isNearTheEnd in Chat.utility.js. Is somewhat of a copy of $.fn.isNearTheEnd. It creates a new jquery selector whereas the prior code did not.