简体   繁体   English

第一次图像更改不会淡入或淡出

[英]First Image Change not Fading In or Out

Using this function to swap through images, but when it swaps for the first time it doesn't fade in or out they just swap instantly. 使用此功能可以交换图像,但是当它第一次交换时,它不会淡入或淡出,它们只是立即交换。 Then after the first instant swap it works perfectly does anyone know why this would be? 然后,在第一次即时交换后,它完美地工作了,有人知道为什么会这样吗?

function swapImages(){
  var $active = $('#maincontent .current01');
  var $next = ($('#maincontent .current01').next().length > 0) ? $('#maincontent .current01').next() : $('#maincontent img:first');
  $next.addClass('next01');
  $active.fadeOut(3000)
    $next.fadeIn(3000,function(){
    $active.removeClass('current01');
    $next.removeClass('next01');
    $next.addClass('current01');
    setTimeout ('swapImages()', 7000);
  });
}

// Run our swapImages() function every 5secs
setTimeout('swapImages()', 6000);

Cheers, AD 干杯,公元

If youre using jQuery i would just use Cycle . 如果您使用jQuery,我只会使用Cycle Its perfect for this. 这是完美的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM