Skip to content

Commit

Permalink
Continue scrolling until bottom is reached (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasimi committed Sep 24, 2016
1 parent 6525201 commit deb0c9e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions styles/all/template/javascript/mchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,8 @@ jQuery(function($) {
}
mChat.messageIds.push($message.data('mchat-id'));
setTimeout(function() {
var $container = mChat.cached('messages');
var dataAddMessageAnimateBefore = {
container: $container,
container: mChat.cached('messages'),
message: $message,
add: function() {
if (mChat.messageTop) {
Expand All @@ -377,16 +376,21 @@ jQuery(function($) {
}
},
show: function() {
var scrollTop = this.container.scrollTop();
var scrollHeight = mChat.messageTop ? 0 : $container.get(0).scrollHeight;
if (mChat.messageTop && scrollTop == 0 || !mChat.messageTop && scrollTop >= scrollHeight - this.container.height()) {
var container = this.container;
var scrollTop = container.scrollTop();
if (mChat.messageTop && scrollTop == 0 || !mChat.messageTop && scrollTop >= container.get(0).scrollHeight - container.height()) {
var animateOptions = {
duration: dataAddMessageBefore.delay - 10,
easing: 'swing'
};
this.message.slideDown(animateOptions);
if (!mChat.messageTop) {
this.container.animate({scrollTop: scrollHeight}, animateOptions);
(animateOptions.complete = function() {
var scrollHeight = container.get(0).scrollHeight;
if (container.scrollTop() + container.height() < scrollHeight) {
container.animate({scrollTop: scrollHeight}, animateOptions);
}
})();
}
} else {
this.message.show();
Expand Down

0 comments on commit deb0c9e

Please sign in to comment.