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.$el.scrollTop(this.el.scrollHeight); // TODO: Avoid scrolling if user has manually scrolled up?
|
||||||
this.measureScrollPosition();
|
this.measureScrollPosition();
|
||||||
} else if (index === 0) {
|
} else if (index === 0) {
|
||||||
|
// add to top
|
||||||
|
this.measureScrollPosition();
|
||||||
this.$el.prepend(view.el);
|
this.$el.prepend(view.el);
|
||||||
|
this.scrollToBottomIfNeeded();
|
||||||
} else {
|
} else {
|
||||||
// insert
|
// insert
|
||||||
this.measureScrollPosition();
|
this.measureScrollPosition();
|
||||||
|
@ -74,13 +77,17 @@
|
||||||
} else {
|
} else {
|
||||||
// scan for the right spot
|
// scan for the right spot
|
||||||
var elements = this.$el.children();
|
var elements = this.$el.children();
|
||||||
for (var i in elements) {
|
if (elements.length > 0) {
|
||||||
var m = this.collection.get(elements[i].id);
|
for (var i = 0; i < elements.length; ++i) {
|
||||||
var m_index = this.collection.indexOf(m);
|
var m = this.collection.get(elements[i].id);
|
||||||
if (m_index > index) {
|
var m_index = this.collection.indexOf(m);
|
||||||
view.$el.insertBefore(elements[i]);
|
if (m_index > index) {
|
||||||
break;
|
view.$el.insertBefore(elements[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
this.$el.append(view.el);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.scrollToBottomIfNeeded();
|
this.scrollToBottomIfNeeded();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue