diff media/js/openwebchat.js @ 75:fb25fead3374

displaying long conversations shouldn't be as jerky now.
author Atul Varma <varmaa@toolness.com>
date Thu, 30 Apr 2009 16:27:06 -0700
parents 878871076cfa
children 16a18e3a1098
line wrap: on
line diff
--- a/media/js/openwebchat.js	Thu Apr 30 14:12:54 2009 -0700
+++ b/media/js/openwebchat.js	Thu Apr 30 16:27:06 2009 -0700
@@ -179,7 +179,10 @@
     $('#outgoing-message').keydown(onKey);
     $('#outgoing-message').keyup(onKey);
 
-    function onMessage(msg) {
+    function onMessage(msg, doAnimation) {
+      if (typeof(doAnimation) == "undefined")
+        doAnimation = true;
+
       var block = $('#templates .message').clone();
 
       if (owStorage.get('lastMessage') == msg.content)
@@ -198,7 +201,7 @@
       block.hide();
       $('#incoming-messages').append(block);
 
-      if (animatingMessages < MAX_ANIMATING_MESSAGES) {
+      if (doAnimation && animatingMessages < MAX_ANIMATING_MESSAGES) {
         animatingMessages += 1;
 
         block.slideDown(
@@ -211,14 +214,14 @@
     }
 
     var currStoredMessage = 0;
-    var CHUNK_SIZE = 20;
+    var CHUNK_SIZE = 100;
     var UI_BREATHE_TIME = 10;
 
     function showStoredConversation() {
       if (currStoredMessage < convStorage.length) {
         var i = 0;
         while (i < CHUNK_SIZE && currStoredMessage < convStorage.length) {
-          onMessage(convStorage.get(currStoredMessage));
+          onMessage(convStorage.get(currStoredMessage), false);
           currStoredMessage += 1;
           i += 1;
         }