Some improvements to scrolling.
This commit is contained in:
parent
36306c7418
commit
3b2b4ed6c7
33
converse.js
33
converse.js
@ -1399,6 +1399,7 @@
|
|||||||
fullname = this.model.get('fullname') || msg_dict.fullname,
|
fullname = this.model.get('fullname') || msg_dict.fullname,
|
||||||
extra_classes = msg_dict.delayed && 'delayed' || '',
|
extra_classes = msg_dict.delayed && 'delayed' || '',
|
||||||
num_messages = this.model.messages.length,
|
num_messages = this.model.messages.length,
|
||||||
|
has_scrollbar = $content.get(0).scrollHeight > $content[0].clientHeight,
|
||||||
template, username, insertMessage;
|
template, username, insertMessage;
|
||||||
|
|
||||||
// FIXME: A better approach here is probably to look at what is
|
// FIXME: A better approach here is probably to look at what is
|
||||||
@ -1407,7 +1408,11 @@
|
|||||||
// That way we could probably also better show day indicators.
|
// That way we could probably also better show day indicators.
|
||||||
// That code should perhaps go into onMessageAdded
|
// That code should perhaps go into onMessageAdded
|
||||||
if (num_messages && msg_time.isBefore(this.model.messages.at(0).get('time'))) {
|
if (num_messages && msg_time.isBefore(this.model.messages.at(0).get('time'))) {
|
||||||
insertMessage = $content.prepend.bind($content);
|
if (! has_scrollbar || $content.scrollTop() !== 0) {
|
||||||
|
insertMessage = _.compose(this.scrollDown.bind(this), $content.prepend.bind($content));
|
||||||
|
} else {
|
||||||
|
insertMessage = $content.prepend.bind($content);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
insertMessage = _.compose(this.scrollDown.bind(this), $content.append.bind($content));
|
insertMessage = _.compose(this.scrollDown.bind(this), $content.append.bind($content));
|
||||||
}
|
}
|
||||||
@ -1495,7 +1500,7 @@
|
|||||||
converse.incrementMsgCounter();
|
converse.incrementMsgCounter();
|
||||||
}
|
}
|
||||||
if (!this.model.get('minimized') && !this.$el.is(':visible')) {
|
if (!this.model.get('minimized') && !this.$el.is(':visible')) {
|
||||||
this.show();
|
_.debounce(this.show, 100);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1959,15 +1964,21 @@
|
|||||||
if (this.$el.is(':visible') && this.$el.css('opacity') == "1") {
|
if (this.$el.is(':visible') && this.$el.css('opacity') == "1") {
|
||||||
return this.focus();
|
return this.focus();
|
||||||
}
|
}
|
||||||
this.$el.fadeIn(callback);
|
this.$el.fadeIn(function () {
|
||||||
if (converse.connection.connected) {
|
if (typeof callback == "function") {
|
||||||
// Without a connection, we haven't yet initialized
|
callback.apply(this, arguments);
|
||||||
// localstorage
|
}
|
||||||
this.model.save();
|
if (converse.connection.connected) {
|
||||||
this.initDragResize();
|
// Without a connection, we haven't yet initialized
|
||||||
}
|
// localstorage
|
||||||
this.setChatState(ACTIVE);
|
this.model.save();
|
||||||
return this.scrollDown().focus();
|
this.initDragResize();
|
||||||
|
}
|
||||||
|
this.setChatState(ACTIVE);
|
||||||
|
this.scrollDown().focus();
|
||||||
|
}.bind(this)
|
||||||
|
);
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollDown: function () {
|
scrollDown: function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user