I have 2 divs, one div(div2) functions as an overlay that has to be triggered when mouseover on the first div(div1). But when i move my mouse around while still in div(1) the other div(div2) keeps triggering. I tried to add a stop before my animate function but it does not seem to work. Is there another way to stop my div(div2) from triggering? Heres my jQuery code:
jQuery('.Mainbutton_hoverwrapper').promise().done(function(){
jQuery('.Mainbutton_hoverwrapper').mouseover(function() {
console.log(jQuery(this).find( '.fusion-button-wrapper' ).width());
jQuery(this).find( '.fusion-button-wrapper' ).css('left', '-' + jQuery(this).width()*2 + 'px');
jQuery(this).find( '.Mainbutton_hover' ).css('display', 'block');
jQuery(this).find( '.fusion-button-wrapper' ).stop( true, true ).animate({left:'0px'});
})
.mouseout(function() {
jQuery(this).find( '.Mainbutton_hover' ).css('display', 'none');
jQuery(this).find( '.fusion-button-wrapper' ).stop( true, true ).animate({left: '-' + jQuery(this).width()*2 + 'px'});
});
});
The animate on itself works fine when executed one time.
EDIT: I tried mouseenter but when i move my mouse the div2 goes away again. Weird behaviour.
EDITED CODE:
jQuery('.Mainbutton_hoverwrapper').mouseenter(function() {
console.log(jQuery(this).find( '.fusion-button-wrapper' ).width());
jQuery(this).find( '.fusion-button-wrapper' ).css('left', '-' + jQuery(this).width()*2 + 'px');
jQuery(this).find( '.Mainbutton_hover' ).css('display', 'block');
jQuery(this).find( '.fusion-button-wrapper' ).stop( true, true ).animate({left:'0px'});
})
.mouseout(function() {
jQuery(this).find( '.Mainbutton_hover' ).css('display', 'none');
jQuery(this).find( '.fusion-button-wrapper' ).stop( true, true ).animate({left: '-' + jQuery(this).width()*2 + 'px'});
});