Mercurial > cosocket
changeset 49:4e21d301ea27
Added a cap on the max num of messages that can be animating at once, so that browsers don't get overloaded.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Tue, 28 Apr 2009 19:00:16 +0000 |
parents | 9c66f1f840f7 |
children | f78b986ecb6e |
files | openwebchat.js |
diffstat | 1 files changed, 14 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/openwebchat.js Tue Apr 28 17:57:35 2009 +0000 +++ b/openwebchat.js Tue Apr 28 19:00:16 2009 +0000 @@ -41,6 +41,9 @@ $(window).ready( function() { var ENTER_KEYCODE = 13; + var MAX_ANIMATING_MESSAGES = 3; + + var animatingMessages = 0; $('#outgoing-message').focus(); @@ -77,10 +80,17 @@ block.hide(); $('#incoming-messages').append(block); - block.slideDown( - function() { - window.scrollTo(0, $('#bottom').position().top); - }); + + if (animatingMessages < MAX_ANIMATING_MESSAGES) { + animatingMessages += 1; + + block.slideDown( + function() { + animatingMessages -= 1; + window.scrollTo(0, $('#bottom').position().top); + }); + } else + block.show(); }, onError: function onError(exception) { if (window.console)