# HG changeset patch # User Stephen Holt # Date 1257030163 14400 # Node ID b0e9a4466823173a9923448d8c420dd059ffde36 # Parent b935d043c4094d3c986ada7510cddd1ac6337bac Only set shouldScroll property on the first new message. Prevents a long cascade of new messages from busting the scroll position before calling nearBottom(). Also, remove an unecessary call to setAppendElementMethod() diff -r b935d043c4094d3c986ada7510cddd1ac6337bac -r b0e9a4466823173a9923448d8c420dd059ffde36 Plugins/WebKit Message View/Template.html --- a/Plugins/WebKit Message View/Template.html Sat Oct 31 16:13:40 2009 -0400 +++ b/Plugins/WebKit Message View/Template.html Sat Oct 31 19:02:43 2009 -0400 @@ -28,18 +28,9 @@ this.isConsecutive = undefined; this.shouldScroll = undefined; - var appendElement = undefined; - - // hook in a custom method to append new data - // to the chat. - this.setAppendElementMethod = function (func) { - if(typeof func === 'function') - appendElement = func; - } - - this.setAppendElementMethod(function (elem) { + var appendElement = function (elem) { document.getElementById("Chat").appendChild(elem); - }); + }; function outputHTML() { var insert = document.getElementById("insert"); @@ -75,6 +66,18 @@ insert.parentNode.removeChild(insert); } + function setShouldScroll(flag) { + if(flag && undefined === self.shouldScroll) + self.shouldScroll = flag; + } + + // hook in a custom method to append new data + // to the chat. + this.setAppendElementMethod = function (func) { + if(typeof func === 'function') + appendElement = func; + } + // (re)start the coalescing timer. // we wait 25ms for a new message to come in. // If we get one, restart the timer and wait another 10ms. @@ -115,7 +118,7 @@ node = null; - if(shouldScroll) self.shouldScroll = shouldScroll; + setShouldScroll(shouldScroll); self.coalesce(); } @@ -130,8 +133,7 @@ self.fragment.appendChild(node); } node = null; - if(shouldScroll) - self.shouldScroll = shouldScroll; + setShouldScroll(shouldScroll); self.coalesce(); } @@ -141,8 +143,7 @@ var lastMessage = self.fragment.lastChild; lastMessage.parentNode.replaceChild(node, lastMessage); node = null; - if(shouldScroll) - self.shouldScroll = shouldScroll; + setShouldScroll(shouldScroll); } } var coalescedHTML;