I am facing a challenge with a div element that has limited height and width, but its content exceeds the size of the div. To address this, I have placed two images at the top and bottom of the div. My intention is to allow the content to scroll up and down based on the image I hover over. While I have managed to achieve the hovering effect, it seems uncontrolled as the scrolling continues till the end even if I move my mouse away from the image. I would like the scrolling to stop immediately when I move my mouse away, and resume from where it left off when I hover over the image again. jsfiddle
HTML:
<div id="hover"> HOVER ME </div>
<div id="container">
The Mauritius Blue Pigeon is an extinct species of blue pigeon formerly endemic to the Mascarene island of Mauritius in the Indian Ocean east of Madagascar. It has two extinct relatives from the Mascarenes and three extant ones from other islands. ...
# CSS code removed for brevity
JAVASCRIPT:
$('#hover').hover(function(){
$('#container').animate({ scrollTop: $('#container')[0].scrollHeight }, 1000);
});
$('#hover2').hover(function(){
$('#container').animate({ scrollTop: 0 }, 1000);
});