I've built a small chat div where people can chat. It works with AJAX which pulls to records and places them.
Everything is working fine except for a minor problem. Every time AJAX is called I want it to scroll the div down to the bottom. (Latest chat messages are on the bottom)
However, I can't figure out how to track if a user is already scrolling inside the chat div themselves or not.
I want to prevent the "auto scroll down" in case a user is active inside the chat.
How would I go around doing this?
HTML of the chat:
<div id="chat">
<div id="chatoutput></div>
</div>
Javascript that makes it scroll to the bottom:
jQuery("#chat").scrollTop($("#chat")[0].scrollHeight);