Scroll to bottom when adding a new message (#1450)

Added a comment to try to make this easier to understand as you read it.

FREEBIE
This commit is contained in:
Scott Nonnenberg 2017-09-07 14:23:51 -07:00
parent 1b444a5e23
commit db869c6ce4
No known key found for this signature in database
GPG key ID: A4931C09644C654B

View file

@ -48,7 +48,12 @@
this.$el.scrollTop(this.scrollPosition - this.$el.outerHeight());
},
scrollToBottomIfNeeded: function() {
if (!this.atBottom()) {
// This is counter-intuitive. Our current bottomOffset is reflective of what
// we last measured, not necessarily the current state. And this is called
// after we just made a change to the DOM: inserting a message, or an image
// finished loading. So if we were near the bottom before, we _need_ to be
// at the bottom again. So we scroll to the bottom.
if (this.atBottom()) {
this.scrollToBottom();
}
},