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

Forum Thread

Palpad doesn't scroll down automatically [+solve]

Forum-Index Bugs/Complaints Solved Palpad doesn't scroll down automatically [+solve]
SwampFall
OFFLINE
Trainerlevel: 59

Forum Posts: 604
Posted: Thu, 13/09/2018 23:49 (5 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
OFFLINE
Trainerlevel: 69

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