Log In
Interaction Multiplier IconNormal Weather Castform Don't have an account yet? Register now!
.

Forum Thread

Palpad doesn't scroll down automatically [+solve]

Forum-Index Bug Reports Resolved Palpad doesn't scroll down automatically [+solve]
SwampFall
OFFLINE
Trainerlevel: 59

Forum Posts: 601
Posted: Thu, 13/09/2018 23:49 (6 Years ago)
Currently it only scrolls down when the message box gets focussed, which only happens when you open a chat.
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"));}});
Riako
ONLINE
Trainerlevel: 70

Forum Posts: 2,773
Posted: Sun, 16/09/2018 21:18 (6 Years ago)
Implemented your patch, thanks :)