【问题标题】:jQuery animate after resize调整大小后的jQuery动画
【发布时间】:2013-11-02 12:52:19
【问题描述】:

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

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

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

【问题讨论】:

  • 控制台是否出现任何错误?
  • 不,萤火虫中什么都没有

标签: javascript jquery html css centering


【解决方案1】:

根据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

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

【讨论】:

  • @Darko 欢迎您。如果您不介意(或没有得到更好的答案),请记得标记为答案。
猜你喜欢
  • 2014-06-20
  • 2019-04-07
  • 1970-01-01
  • 2014-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多