Skip to content
Permalink
Browse files

Continue scrolling until bottom is reached (#1)

  • Loading branch information...
kasimi committed Sep 24, 2016
1 parent 6525201 commit deb0c9ed6371284760c5eef930c0819ce616ae66
Showing with 10 additions and 6 deletions.
  1. +10 −6 styles/all/template/javascript/mchat.js
@@ -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) {
@@ -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();

0 comments on commit deb0c9e

Please sign in to comment.
You can’t perform that action at this time.