0

I already have a script for mouse enter, but I can't figure out leave statement from side. Objective is to animate .darker to enter from side which mouse does, and also leave to side where mouse leaved.

$('body').on('mouseenter', '.article', function(e){
    if(e.offsetX < 10){
        side = "left";
        $('.darker', this).css('top', '0');
        $('.darker', this).css('left', '-325px');
        $('.darker', this).animate({
            left: 0
        },200,function(){});
    }
});

Do you have any idea how to determine leaving from side? Thank you for help!

Michael Irigoyen
  • 22,513
  • 17
  • 89
  • 131
  • Do you mean you're trying to figure out if the mouse enters an element from the left or the right side? If so, look at http://stackoverflow.com/questions/8575951/jquery-mouse-direction-plugin and http://stackoverflow.com/questions/8450199/detect-mouse-direction. – EmmyS Feb 22 '13 at 20:22
  • Are you trying to figure out when mouse leaves the screen? – Dom Feb 22 '13 at 22:32

1 Answers1

0

Take a look at mouse events, basically 'mouseover' and 'mouseout' are the events you want.

Skim through this excellent link for mouse events for details

For a jQuery specific answer look at .mouseover() and .mouseout() in jQuery API docs

gashu
  • 484
  • 6
  • 17