1

我正在使用jQuery Image Center 插件并尝试在图像居中后对其进行动画处理

这是我的代码,图像居中有效,但动画无效

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

1 回答 1

0

根据插件源,第二个参数是回调和第一个居中方法。所以试试

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);
});

演示

演示2

还请记住,您可以像在演示中那样将它们链接起来。

于 2013-10-24T01:40:57.577 回答