0

For the site I am currently building, I want to utilize cycling images for one section (IE a series of images crossfade in a single container.) As this is largely a learning process for me, I am writing most of the javascript and jQuery myself instead of using prebuilt plugins.

The cycle works perfectly (as far as I can tell) on all desktop browsers, but when tested on iOS devices, I get a flicker each time a section starts to cycle to a new image.

Basically, there are three functions that look like this:

function cycleTheatrical(){
   setTimeout(function(){
    (theatPos < (theatArray.length-1)) ? theatPos+=1 : theatPos = 0;
    $('#page-1-theatrical').append("<img src='" + theatArray[theatPos] + "' class='project-img' style='display:none'>");
    $('#page-1-theatrical img:last-child').fadeIn(1500, function(){
    $('#page-1-theatrical img:first').remove();
    });
    cycleHomeEnt();
}, 3000);
};

So what I am attempting to do is to append the new image with display:none, then fade it in over the old one. Once faded in, the callback function removed the old image.

When viewed in an iOS device, I see a brief flash of the new image, just for one fraction of a second, before it disappears and the cross fade happens normally. My first assumption was that the display:none was not getting set until after the image was set, so I build an alternate version that appended an image with no source set to display:none, then added a source in ( using .attr() ) before doing the fade, but the problem remained the same as before.

So does anyone know what causes this brief flicker on iOS devices? You can view the WIP site here, to see what I am talking about:

http://www.thecrpgroup.com/crpweb/promo-site/

Thanks for any help!

4

1 回答 1

0

我不知道为什么需要这样做,但我确实找到了答案。在使用它之后,我将问题隔离到了 fadeIn() 调用。这让我缩小了搜索范围,我发现了这个:

Jquery当FadeIn()它闪烁的对象时,Ipad safari

事实证明,用fadeTo() 替换fadeIn() 解决了这个问题。

于 2013-09-04T22:14:06.640 回答