<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,2 +1,3 @@
 *.swp
 .DS_Store
+http/tmp</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -11,6 +11,11 @@ JsChat.ChatController = Class.create({
     Event.observe(window, 'resize', this.resizeEvent.bindAsEventListener(this));
 
     $('post_message').observe('submit', this.postMessageFormEvent.bindAsEventListener(this));
+    $('messages').observe('scroll', this.messagesScrolled.bindAsEventListener(this));
+  },
+
+  messagesScrolled: function() {
+    Display.scrolled = (($('messages').scrollHeight - $('messages').scrollTop) &gt; $('messages').getHeight());
   },
 
   focusEvent: function() {</diff>
      <filename>http/public/javascripts/app/controllers/chat_controller.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,18 @@
 var Display = {
+  scrolled: false,
+
   add_message: function(text, className, time) {
     var time_html = '&lt;span class=&quot;time&quot;&gt;\#{time}&lt;/span&gt;'.interpolate({ time: TextHelper.dateText(time) });
     $('messages').insert({ bottom: '&lt;li class=&quot;' + className + '&quot;&gt;' + time_html + ' ' + text + '&lt;/li&gt;' });
     this.scrollMessagesToTop();
   },
 
+  addImageOnLoads: function() {
+    $$('#messages li').last().select('img').each(function(element) {
+        element.observe('load', this.scrollMessagesToTop);
+    }.bind(this));
+  },
+
   message: function(message) {
     var name = $('name').innerHTML;
     var user_class = name == message['user'] ? 'user active' : 'user';
@@ -19,6 +27,8 @@ var Display = {
     text = text.interpolate({ user_class: user_class, room: message['room'], user: TextHelper.truncateName(message['user']), message: TextHelper.decorateMessage(message['message']), message_class: 'message' });
     this.add_message(text, 'message', message['time']);
 
+    this.addImageOnLoads();
+
     if (this.show_unread) {
       this.unread++;
       document.title = 'JsChat: (' + this.unread + ') new messages';
@@ -48,7 +58,9 @@ var Display = {
   },
 
   scrollMessagesToTop: function() {
-    $('messages').scrollTop = $('messages').scrollHeight;   
+    if (!this.scrolled) {
+      $('messages').scrollTop = $('messages').scrollHeight;
+    }
   },
 
   clearIdleState: function(user_name) {</diff>
      <filename>http/public/javascripts/app/protocol/display.js</filename>
    </modified>
    <modified>
      <diff>@@ -3,10 +3,6 @@
   &lt;p&gt;JsChat is an &lt;em&gt;open source&lt;/em&gt; chat system that uses a simple protocol based on &lt;acronym title=&quot;JavaScript Object Notation&quot;&gt;JSON&lt;/acronym&gt;.&lt;/p&gt;
   &lt;p&gt;To download the code and an irssi-like &lt;em&gt;console client&lt;/em&gt;, visit &lt;a href=&quot;http://github.com/alexyoung/jschat/&quot;&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
   &lt;p&gt;Read more on the &lt;a href=&quot;http://blog.jschat.org&quot;&gt;JsChat Blog&lt;/a&gt;.&lt;/p&gt;
-  &lt;div class=&quot;big_message&quot;&gt;
-    &lt;h2 class=&quot;angry&quot;&gt;Stop Asking Us About Polling&lt;/h2&gt;
-    &lt;p&gt;Read how and why JsChat's web interface works here: &lt;a href=&quot;http://blog.jschat.org/post/114748445/jschat-polling&quot;&gt;JsChat: Polling&lt;/a&gt;.&lt;/p&gt;
-  &lt;/div&gt;
   &lt;h2&gt;Try JsChat Now&lt;/h2&gt;
   &lt;div id=&quot;feedback&quot; class=&quot;error&quot; style=&quot;display: none&quot;&gt;&lt;/div&gt;
   &lt;form method=&quot;post&quot; action=&quot;/identify&quot; id=&quot;sign-on&quot;&gt;</diff>
      <filename>http/views/index.erb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8da3235ea7559f2c67172c58beb667e6e741351e</id>
    </parent>
  </parents>
  <author>
    <name>Alex Young</name>
    <email>alex@helicoid.net</email>
  </author>
  <url>http://github.com/alexyoung/jschat/commit/9e9951ac4632e33a49005c40796865bd6e772a15</url>
  <id>9e9951ac4632e33a49005c40796865bd6e772a15</id>
  <committed-date>2009-06-05T02:30:38-07:00</committed-date>
  <authored-date>2009-06-05T02:30:38-07:00</authored-date>
  <message>Added image onload handling to scroll the message pane down, and it also stops scrolling when you scroll away from the bottom</message>
  <tree>568096c0e476622af7581a1c7aabb67735c26433</tree>
  <committer>
    <name>Alex Young</name>
    <email>alex@helicoid.net</email>
  </committer>
</commit>
