From a61e6905bc1432557c8215c7857382de0391424e Mon Sep 17 00:00:00 2001 From: Pierre Date: Sat, 28 Apr 2018 10:04:12 +0200 Subject: [PATCH] Made slimscroll more user friendly when scrolling up in conversations --- assets/js/components/conversations/chatWindows.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/assets/js/components/conversations/chatWindows.js b/assets/js/components/conversations/chatWindows.js index 904fec26..ab83cd56 100644 --- a/assets/js/components/conversations/chatWindows.js +++ b/assets/js/components/conversations/chatWindows.js @@ -759,6 +759,9 @@ ComunicWeb.components.conversations.chatWindows = { //Else extract conversation informations var conv = this.__conversationsCache["conversation-"+conversationID]; + //Save the position of the oldest message element + var currOldestMessageElem = conv.messages[0].rootElem; + //Process the list of messages in reverse order messages.reverse(); messages.forEach(function(message){ @@ -777,6 +780,13 @@ ComunicWeb.components.conversations.chatWindows = { }); + //Update slimscroll + newScrollPos = currOldestMessageElem.offsetTop - 30; + if(newScrollPos < 0) + newScrollPos = 0; + $(conv.box.messagesArea).slimScroll({ + scrollTo: newScrollPos + "px" + }); }, /**