autoscroll issue

Help
Chris
2012-09-27
2012-11-15
  • Chris
    Chris
    2012-09-27

    I've seen this problem around the forums, but no one has an answer that I could find.  The chat window hangs at about 20px above the bottom so the most recent message can't be seen.  It does this in chrome v22 and safari v6.  Firefox v15 works just fine.

    If anyone has a fix for this it would be great. 

    A little more info I found: if you insert a picture the window with the image tags the scroll window works and scrolls to the bottom.  But any text does not.

    Thoughts? Fixes?

     
  • I have a fix for this provided to me by Johnny from baconpunch.com

    Since I don't have safari I can't reproduce it at the moment but it seems to be a fairly common issue with safari users, and not just with ajax chat. Safari just doesn't like scrolling unless you delay it via a setTimeout

    Anyway open js/chat.js and find this:

    this.dom['chatList'].scrollTop = this.dom['chatList'].scrollHeight;
    

    It appears twice and is the means by which chat auto scrolls. Replace both instances of it with this:

    //this.dom['chatList'].scrollTop = this.dom['chatList'].scrollHeight;
    setTimeout(this.scrollChatToBottom,1);
    

    Next, find the following:
    encodeText: function(text) {

    Just before that, add this:

    scrollChatToBottom: function() {
            // note: we cannot use this.dom, since this method's "this" refers to the window object when called with setTimeout()
            ajaxChat.dom['chatList'].scrollTop = ajaxChat.dom['chatList'].scrollHeight;
    },
    

    Let me know how that goes.