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
6 odpowiedzi
+ 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.
+ 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.
+ 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
+ 1
Sorry, that wouldn't work.
I've edited it to the right answer
+ 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
0
could trigger it with my success callback function in Ajax