0

Anyone known how to make div autoscroll but allow others to scroll up still too

I want it to autoscroll when a new message is added to the div but allow users to still be able to scroll upwards

14th Sep 2017, 12:21 AM
Styxincewa
Styxincewa - avatar
6 Answers
+ 3
Trigger this function whenever a message is sent. [EDITED] function scroll(){ var div_length = $("your_div_id").innerHeight(); $('#your_div_id').animate({scrollTop: div_length}, 800); return false; }); Replace "your_div_id" with the id of the element you want to scroll to the bottom of. Trigger "scroll()" whenever a new message comes in.
14th Sep 2017, 12:35 AM
Leigh E. O.
Leigh E. O. - avatar
+ 2
@Modded, this is for your chatroom, right? If so, you should add an autoscroll system that triggers whenever a new message is sent or received. It'll be better than having to manually scroll, every time.
14th Sep 2017, 8:45 AM
Leigh E. O.
Leigh E. O. - avatar
+ 1
basically what I have currently for autoscroll is every 3500 milliseconds the scrollTop is set the value of 2147483647 so it will always scroll, but I want to allow users to scroll up too and it to only scroll when a new message is sent to the chatroom
14th Sep 2017, 12:23 AM
Styxincewa
Styxincewa - avatar
+ 1
Sorry, that wouldn't work. I've edited it to the right answer
14th Sep 2017, 12:46 AM
Leigh E. O.
Leigh E. O. - avatar
+ 1
it probably would work but better to not do it when message is sent though as it wouldn't actually scroll as it's been scrolled before the message has loaded into the div
14th Sep 2017, 6:52 AM
Styxincewa
Styxincewa - avatar
0
could trigger it with my success callback function in Ajax
14th Sep 2017, 4:32 AM
Styxincewa
Styxincewa - avatar