At the moment when I hover over each li, the corresponding image fades in and out. However when i hover from one nav li to another, the fade out of the first image is interrupted and the second image fades in. I am looking for a smooth cross fade from of the images when I hover from one nav li to another. similar to the effect in this website: http://www.bonnieroccelli.com/
Any help would be massively appreciated!
html:
<div class="banner-nav-wrap">
<ul>
<li class="banner-nav-item" data-img="images/home-banner.png">List item 1</li>
<li class="banner-nav-item" data-img="images/1.jpg">List item 2</li>
<li class="banner-nav-item" data-img="images/6.jpg">List item 3</li>
</ul>
</div>
jquery:
<script type="text/javascript">
$('.banner-nav-item').hover(function() {
var img = $(this).attr('data-img');
$('img#hover-img').css({"display" : "none"});
$('img#hover-img').fadeIn('slow').attr('src', img);
},function() {
$('img#hover-img').fadeOut('slow');
});
</script>