JavaScript some issues with mouseenter and mouseleave functions some issues with,some issues with health,some issues with

I have this function:

$(".insidediv").hide();

$(".floater").mouseenter(function(){
    $(".hideimg").fadeOut(function(){
        $(".insidediv").fadeIn();
    });
});

$(".floater").mouseleave(function(){
    $(".insidediv").fadeOut(function(){
        $(".hideimg").fadeIn();
    });
});

the function built to make a little animation, when you 'mouseenter' the div the picture I have there is hidden and than a few text show up. it works fine if i move the mouse slowly. but if i move my mouse fast over the div the function getting confused or something and it shows me both '.insidediv and .hideimg, how can i fixed that little problem so it wont show me both? thanks!

Answer:1

You need to reset the opacity, because fadeIn and fadeOut uses this css property for animation. Just stopping the animation is not enough.

This should work:

var inside = $(".insidediv"),
img = $(".hideimg");
duration = 500;

inside.hide();

$(".floater").mouseenter(function () {
    if (inside.is(":visible"))
        inside.stop().animate({ opacity: 1 }, duration);
    img.stop().fadeOut(duration, function () {
        inside.fadeIn(duration);
    });
});

$(".floater").mouseleave(function () {
    if (img.is(":visible"))
        img.stop().animate({ opacity: 1 }, duration);
    inside.stop().fadeOut(duration, function () {
        img.fadeIn(duration);
    });
});

I just introduced the duration variable to get animations of equal length.

Here is a working fiddle: http://jsfiddle.net/eau7M/1/ (modification from previous comment on other post)

Answer:2

try this:

var $insideDiv = $(".insidediv");
var $hideImg = $(".hideimg");
$insideDiv.hide();
$(".floater").mouseenter(function(){
    $hideImg.finish().fadeOut(function(){
        $insideDiv.fadeIn();
    });
}).mouseleave(function(){
    $insideDiv.finish().fadeOut(function(){
        $hideImg.fadeIn();
    });
});
Answer:3

This will solve your issue:

var inside = $(".insidediv"),
img = $(".hideimg");

inside.hide();

$(".floater").hover(function () {
img.stop(true).fadeOut('fast',function () {
    inside.stop(true).fadeIn('fast');
 });

},function () {
inside.stop(true).fadeOut('fast',function () {
    img.stop(true).fadeIn('fast');
});
});

Updated Fiddle

Answer:4

Is there a way to receive the data from pay-pal that comes out when someone has confirmed they have bought my item and the payment has gone through? I am looking to then use this data to remove an ...

Is there a way to receive the data from pay-pal that comes out when someone has confirmed they have bought my item and the payment has gone through? I am looking to then use this data to remove an ...

  1. receive data from bluetooth android code

I have HTML like: <div id="hooray" class="section"> <div> <div> <div id="click">click</div> </div> </div> </div> When I ...

I have HTML like: <div id="hooray" class="section"> <div> <div> <div id="click">click</div> </div> </div> </div> When I ...

How can I partially sort an array in JavaScript, based on some conditions that I choose? Given an array var tab = [ {html: 'This is a test'}, {html: 'Locked item', locked: true}, {html:...

How can I partially sort an array in JavaScript, based on some conditions that I choose? Given an array var tab = [ {html: 'This is a test'}, {html: 'Locked item', locked: true}, {html:...

  1. sort partially sorted array
  2. c++ partial sort an array
  3. best sort for partially sorted array
  4. sorting partially sorted array

I am new to google api. I am able to do this file upload from app script and any file which is uploaded through that script get stored to my drive only. But how to do this using javascript. Example ...

I am new to google api. I am able to do this file upload from app script and any file which is uploaded through that script get stored to my drive only. But how to do this using javascript. Example ...

  1. upload file google drive
  2. upload file google colab
  3. upload file google form
  4. upload file google drive api
  5. upload file google cloud storage
  6. upload file google drive python
  7. upload file google doc
  8. upload file google app script
  9. upload file google storage
  10. upload file google drive php
  11. upload file google sheets
  12. upload file google drive c#
  13. upload file google sites
  14. upload file google cloud storage nodejs
  15. upload file google drive java
  16. upload file google drive android
  17. upload file google drive mobile
  18. upload file google translate