2013-10-24 20 views
1

我使用jQuery Image Center plugin并试图居中jQuery的动画之后调整

后这里是我的代码动画图像,图像为中心的作品,但动画没有

$('#myimage').css('opacity' , 0); 
$('#myimage').centerImage(function() { 
    //At this point, resize is complete, and the element is invisible 
    $(this).animate({opacity: 1}, 1500); 
}); 
+0

你在控制台上是否有任何错误? –

+0

不,没有在萤火虫 – Darko

回答

0

按照plugin source,第二个参数是回调和第一个居中方法。因此,尝试

var $img =$('#myimage'); 
$img.css('opacity', 0); 

$img.centerImage('inside', function() { //give inside or for no method just provide undefined or "" 
     //At this point, resize is complete, and the element is invisible 
    $(this).animate({ 
     opacity: 1 
    }, 1500); 
}); 

Demo

Demo2

也请记住链EM通过在演示。

+0

是的!,这工程,thx – Darko

+0

@达科不客气。如果你不介意(或没有得到更好的答案),请记住标记为答案。 – PSL