Fix message insertion for the first element inserted
This commit is contained in:
parent
d3a2f5c838
commit
94c1ac6f09
1 changed files with 13 additions and 6 deletions
|
@ -60,7 +60,10 @@
|
|||
this.$el.scrollTop(this.el.scrollHeight); // TODO: Avoid scrolling if user has manually scrolled up?
|
||||
this.measureScrollPosition();
|
||||
} else if (index === 0) {
|
||||
// add to top
|
||||
this.measureScrollPosition();
|
||||
this.$el.prepend(view.el);
|
||||
this.scrollToBottomIfNeeded();
|
||||
} else {
|
||||
// insert
|
||||
this.measureScrollPosition();
|
||||
|
@ -74,13 +77,17 @@
|
|||
} else {
|
||||
// scan for the right spot
|
||||
var elements = this.$el.children();
|
||||
for (var i in elements) {
|
||||
var m = this.collection.get(elements[i].id);
|
||||
var m_index = this.collection.indexOf(m);
|
||||
if (m_index > index) {
|
||||
view.$el.insertBefore(elements[i]);
|
||||
break;
|
||||
if (elements.length > 0) {
|
||||
for (var i = 0; i < elements.length; ++i) {
|
||||
var m = this.collection.get(elements[i].id);
|
||||
var m_index = this.collection.indexOf(m);
|
||||
if (m_index > index) {
|
||||
view.$el.insertBefore(elements[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.$el.append(view.el);
|
||||
}
|
||||
}
|
||||
this.scrollToBottomIfNeeded();
|
||||
|
|
Loading…
Reference in a new issue