Skip to content

Commit

Permalink
Changed auto-scrolling in the room so that it only occurs when the br…
Browse files Browse the repository at this point in the history
…owser is already scrolled to the bottom of the page.
  • Loading branch information
stephenmcd committed Feb 1, 2011
1 parent 7d50645 commit 91ec9db
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client.coffee
Expand Up @@ -6,8 +6,12 @@ $ ->
# Write incoming messages to the page and scroll.
socket.on "message", (data) ->
data = JSON.parse data
win = $ window
doc = $ window.document
bottom = win.scrollTop() + win.height() is doc.height()
$("#messages").append "<p>#{data.message}</p>"
window.scrollBy 0, 10000
if bottom
window.scrollBy 0, 10000
if data.users?
heading = "<li><h2>Users</h2> (#{data.users.length})</li>"
users = ("<li>#{user}</li>" for user in data.users).join("")
Expand Down

0 comments on commit 91ec9db

Please sign in to comment.