fadein - Fade in and out with jQuery Image Gallery -


i've made simple jquery image gallery http://jsfiddle.net/rvermeulen/xnshc/3/

but can't make nice fadeout , in in it, because if (with fadeout , in in it):

$(document).ready(function() {      $(".small_image").click(function() {         event.preventdefault();         var image = $(this).attr("rel");         $('#current_image').fadeout(300);         $('#current_image').html('<img width="370" src="' + image + '"/>');         $('#current_image').fadein(300);     });  }); 

it looks .html function loads faster fadein, it's no "smooth" fade. know how fix delay or something?

you need use complete callback change image after image faded out:

$(".small_image").click(function () {     event.preventdefault();     var image = $(this).attr("rel");     $('#current_image').fadeout(300, function() {         $('#current_image').html('<img width="370" src="' + image + '"/>');         $('#current_image').fadein(300);     }); }); 

jsfiddle example


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -