adium 2841:b0e9a4466823: Only set shouldScroll property on the f...

commits at adium.im commits at adium.im
Sat Oct 31 23:21:44 UTC 2009


details:	http://hg.adium.im/adium/rev/b0e9a4466823
revision:	2841:b0e9a4466823
author:		Stephen Holt <sholt at adium.im>
date:		Sat Oct 31 19:02:43 2009 -0400

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()

diffs (72 lines):

diff -r b935d043c409 -r b0e9a4466823 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;




More information about the commits mailing list