aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Kavlie <akavlie@gmail.com>2011-11-14 20:38:38 -0700
committerAaron Kavlie <akavlie@gmail.com>2011-11-14 20:38:38 -0700
commit8b76b19dba433a365b59a684881c91377c98b342 (patch)
tree977f1a613a61f4431bb181d87fa5eeda5e6ab29d
parent5d3e5b90e1e010312544911bf13efa55fd587229 (diff)
downloadreevo-webirc-8b76b19dba433a365b59a684881c91377c98b342.tar.gz
reevo-webirc-8b76b19dba433a365b59a684881c91377c98b342.zip
Fix autoscroll for new messages.
-rw-r--r--public/app.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/public/app.js b/public/app.js
index fe8a03b..861cddd 100644
--- a/public/app.js
+++ b/public/app.js
@@ -203,18 +203,17 @@ $(function() {
203 }, 203 },
204 204
205 addMessage: function(message, single) { 205 addMessage: function(message, single) {
206 // Expensive -- only do this on single message additions 206 // Only do this on single message additions
207 if (single) { 207 if (single) {
208 var position = $('#output #messages').scrollTop(); 208 var position = $('#messages').scrollTop();
209 var atBottom = $('#output #messages')[0].scrollHeight - position 209 var atBottom = $('#messages')[0].scrollHeight - position
210 == $('#output #messages').innerHeight(); 210 == $('#messages').innerHeight();
211 var position = this.$('#output #messages').scrollTop();
212 } 211 }
213 var view = new MessageView({model: message}); 212 var view = new MessageView({model: message});
214 $('#output #messages').append(view.el); 213 $('#messages').append(view.el);
215 // Scroll to bottom on new message if already at bottom 214 // Scroll to bottom on new message if already at bottom
216 if (atBottom) { 215 if (atBottom) {
217 $('#output').scrollTop(position + 100); 216 $('#messages').scrollTop(position + 100);
218 } 217 }
219 }, 218 },
220 219
@@ -231,7 +230,7 @@ $(function() {
231 } 230 }
232 this.focused = frame; 231 this.focused = frame;
233 frames.setActive(this.focused); 232 frames.setActive(this.focused);
234 this.$('#output #messages').empty(); 233 $('#messages').empty();
235 234
236 frame.stream.each(function(message) { 235 frame.stream.each(function(message) {
237 this.addMessage(message, false); 236 this.addMessage(message, false);