views:

209

answers:

1

http://wesbos.com/tf/shutterflow/?cat=3

when one hovers over an image .cover is faded in. I use jquery to change the opacity because CSS doesn't work in IE for this purpose.

My code is:

      $(document).ready(  
        function() {
    $('.slide').hover(
            function() { $(".cover").animate({ opacity: 0.7 },300 ).fadeIn('300'); },
      function () { $(".cover").animate({ opacity: 0 },300 ).fadeOut('300'); 



         }  );
     }  );

I want the fade in to be instant, not wait 1 second. Any ideas?

+2  A: 

You have two different animations happening sequentially: first, .animate({ opacity: 0.7 }, 300) and second .fadeIn(300). Since those are competing effects, it's probably not helping anything to have them both running.

If .fadeIn() will do what you want, try just using that:

$(document).ready(function() {
    $('.slide').hover(
        function() { $(".cover").fadeIn('300'); },
        function() { $(".cover").fadeOut('300'); }
    );
});
VoteyDisciple
Actually, I believe the animations are queued. Thus, the fadeIn occurs 300 ms after "now" because there's an animate in between.
strager
Quite right. Because they're both animations, they should queue correctly. Edited accordingly
VoteyDisciple
Thanks for the revision. This works, however, I need the layer to be 70% transparent when faded in and completely hidden when hover out...
Wes
The animations aren't competing, but that first `.animate()` changes the opacity for 300ms *while .cover is still hidden.* Set opacity to 0.7 in the CSS, then just let fadeIn and fadeOut do their jobs as suggested by VoteyDisciple. Also, why are you trying to block access to the contextual menu? That's not going to stop anyone from stealing your images, but will piss off people browsing the site.
Sidnicious
I have tried using the CSS route. It loads fine, but when the Div fades out and thne back in again, IE renders it with no opacity and it a black square.I am leaving the context menu enabled with an option to disable it. Being a web designer, I hate blocking it. however, it gives photographers peace of mind.
Wes
Since `.fadeIn()` is itself changing the opacity, so perhaps you want to do this the other way around: keep the `.animate()` you had and lose the `.fadeIn()`.
VoteyDisciple