I found a script and want to mod it a bit. Im trying to animate a div #menuwrap when the user is inactive or active over an certain div #gallery.
Now it still animates even outside the #gallery after its animated the first time.
Any help is much appreciated!
Demo: http://jsfiddle.net/m2FvY/1/
$('#gallery').mouseover(function() {
var interval = 1;
setInterval(function(){
if(interval == 5){
$('#menuwrap').animate({top: '-50px'}, 100);
interval = 1;
}
interval = interval+1;
console.log(interval);
},200);
$('#gallery').bind('mousemove keypress', function() {
$('#menuwrap').animate({top: '0'}, 100);
interval = 1;
});
});
JSFIDDLE DEMO
Delay timer resets anytime the user triggers the mousemove or keypress event on #gallery. You could also add the hover event in there to ensure the menu never hides when hovered over #gallery.
ANSWER PART 2
JSFIDDLE DEMO #2
Only checks for inactivity once #gallery events mousemove or keypress have been triggered. Once the user has moved out of the #gallery box, it will kill the delayCheck() and set the #menuwrap back to top: -50px.