From 4c667ecef63bbc1029a8ea272f5fc4acc40b3731 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 7 Feb 2015 23:23:33 +0000 Subject: [PATCH 1/2] fix scroll issue where focus is not well managed --- src/static/js/chat.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/static/js/chat.js b/src/static/js/chat.js index ce9a00337..bdb5ee09c 100644 --- a/src/static/js/chat.js +++ b/src/static/js/chat.js @@ -29,9 +29,11 @@ var chat = (function() var self = { show: function () { +console.log("here"); $("#chaticon").hide(); $("#chatbox").show(); $("#gritter-notice-wrapper").hide(); + console.log("scroll down 1"); self.scrollDown(); chatMentions = 0; Tinycon.setBubble(0); @@ -91,7 +93,9 @@ var chat = (function() { if($('#chatbox').css("display") != "none"){ if(!self.lastMessage || !self.lastMessage.position() || self.lastMessage.position().top < $('#chattext').height()) { - $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "slow"); + // if we use a slow animate here we can have a race condition when a users focus can not be moved away + // from the last message recieved. + $('#chattext').animate({scrollTop: $('#chattext')[0].scrollHeight}, "fast"); self.lastMessage = $('#chattext > p').eq(-1); } } @@ -195,6 +199,7 @@ var chat = (function() }); if(!isHistoryAdd) self.scrollDown(); + console.log("scroll down 2"); }, init: function(pad) { From fe4dd98a6e4df364523564daeb631898523bfdf4 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 7 Feb 2015 23:24:24 +0000 Subject: [PATCH 2/2] remove console logs --- src/static/js/chat.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/static/js/chat.js b/src/static/js/chat.js index bdb5ee09c..5040ea59b 100644 --- a/src/static/js/chat.js +++ b/src/static/js/chat.js @@ -29,11 +29,9 @@ var chat = (function() var self = { show: function () { -console.log("here"); $("#chaticon").hide(); $("#chatbox").show(); $("#gritter-notice-wrapper").hide(); - console.log("scroll down 1"); self.scrollDown(); chatMentions = 0; Tinycon.setBubble(0); @@ -199,7 +197,6 @@ console.log("here"); }); if(!isHistoryAdd) self.scrollDown(); - console.log("scroll down 2"); }, init: function(pad) {