Forum Thread
Palpad doesn't scroll down automatically [+solve]
Forum-Index → Bug Reports → Resolved → Palpad doesn't scroll down automatically [+solve]However I think it'd be better to scrolldown when loadchat.php returns a new message (don't scroll down when it's an empty response)
Current code
$.ajax(... loadchat.php ...
).done(function(msg){$("#private_chat
.chat_inner").append(msg);load_lock=false;});
Code that I think will do the job
$.ajax(... loadchat.php ...
).done(function(msg){$("#private_chat
.chat_inner").append(msg);load_lock=false;if(msg.length>10){$("#private_chat
.chat_inner").scrollTop(1e4);}});
I chose 10 as a length threshold since loadchat always returns
something and if an actual message is returned it's automatically
bigger than 10 cause of all the HTML tags.Edit
When using .scrollTop(1e4); it doesn't always scroll to the bottom when older messages are loaded.
The following code will always scroll to the bottom of the chat.
$.ajax(... loadchat.php ...
).done(function(msg){var c=$("#private_chat
.chat_inner");c.append(msg);load_lock=false;if(msg.length>10){c.scrollTop(c.prop("scrollHeight"
) - c.prop("clientHeight"));}});