davidfowl/JabbR — pull request #559 by dpatti (2012-07-31 04:18:06+00:00)
Title: Various scroll fixes

These are mostly in follow up to #556.

1. I had encountered a situation where a room I was in loaded enough messages to fill barely more than the height of the chat window, so it thought I was passed the threshold before I even tried to scroll. Remedied this by not loading scrollback if you are scrolled to the end.
2. Minor performance change; I was originally attaching load events to all the gravatars, which is unnecessary.
3. This was a bit of a challenge since it was not reproducible when stepping through the debugger, but it turns out that the chat messages are changed after the deferred is resolved, which is immediately after we record the scrollHeight to see if the user tried to move it. I fixed this by attaching the load listeners *after* the deferred is resolved, but I don't know if this is poor practice or not, as I have not used jQuery's deferreds much. Let me know what you think.