Skip to content

Commit

Permalink
Don't auto scroll the window if the user has scrolled up
Browse files Browse the repository at this point in the history
  • Loading branch information
9ary committed Mar 25, 2015
1 parent 66a2c9d commit cc6db27
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion index.js
Expand Up @@ -103,7 +103,14 @@ io.on('connection', function(socket)
socket.emit(rows[i].type,rows[i]);
}
}
socket.emit('scroll',"");
if(data.lines > 1)
{
socket.emit('scrollforce',"");
}
else
{
socket.emit('scroll',"");
}
});

connection.query('SELECT * FROM irc_channels WHERE chan = ?', [config.channel], function(err, rows, fields)
Expand Down
7 changes: 7 additions & 0 deletions public/main.js
Expand Up @@ -198,6 +198,12 @@ socket.on('topics', function(data)
});

socket.on('scroll', function(data)
{
if($(document).height()-$(document).scrollTop()-$(window).height() <= $("#messages tr:last").height()+1)
scroll();
});

socket.on('scrollforce', function(data)
{
scroll();
});
Expand Down Expand Up @@ -337,6 +343,7 @@ $("#send").click(function(e)
socket.emit('message', {message: message, auth: auth, action: 0});
}
$("#inputmsg").val("");
scroll();
}
});

Expand Down

0 comments on commit cc6db27

Please sign in to comment.