I have a jQuery script that scrolls down to the end of a text area box. This function is inside a Interval based auto div reloader (Script Below). I want to make it so when someone is scrolling in the text area, the part of the script scrolling it down is deactivated.
var refreshId = setInterval(function()
{
$('#chatArea').load('run/chatBox.php', function() {
$('#chatAreaBox').scrollTop($('#chatAreaBox')[0].scrollHeight);
});
}, 2500);
Just check the
scrollTopvalue to know if the user has scrolled down before executing animationYou could also store the timestamp (using
date()) in ascroll()event and check it in your interval function, then execute the animation if the last scroll event occurred more than 5 seconds ago