I have the following live example in freakyleaf.co.uk/hoverfade/ , due to which, when falling over a tile, the background image of the tile disappears from 1 to 0.25 opacity 600ms (.tile_img), then the text disappears from 0 to 1 opacity for more than 500 ms (. overlay). When you mouse out, the opposite happens.
All this works fine until the mouse leaves only after the animation is complete. If the mouse leaves during the mouse animation, the tile image disappears to full opacity, but the text does not disappear, leaving it visible.
I have the following code:
$(document).ready(function(){ $(".tile").hoverIntent(function() { $(".tile_img", this).animate({"opacity": "0.25"}, 600, function() { $(this).next(".overlay").animate({"opacity": "1"}, 500); } ); }, function() { $(".overlay", this).animate({"opacity": "0"}, 500, function() { $(this).prev(".tile_img").animate({"opacity": "1"}, 600); } ); }); });
And HTML:
<div class="wrapper"> <ul id="service_boxes"> <li id="sb_recording" class="tile" onClick="location.href='recording.php';" style="cursor: pointer;"> <h2><a href="recording.php">Recording</a></h2> <div class="tile_img"></div> <div class="overlay"><p>Vintage analogue warmth and cutting-edge digital technology working in perfect harmony - That the SoundARC sound!</p></div> </li> </ul> </div>
I understand that I should probably use the .stop function, but I tried this in several places, but so far I have broken the code.
I'm not even sure that I have a better way to achieve what I want; I only got to this point by accident, as I am a complete beginner.
Any help would be greatly appreciated.
Thank you very much.