I created a small interactive module where user can shuffle through the images. This module works fine (even if it's not optimised yet) except under iOS. If the user clicks only one image, the shuffling animation is displayed properly however this is not the case when hitting the Shuffle button.
The shuffle button code:
$("#shuffle").click(function(){
$(".slide").each(function(){
var target = $(this);
shuffleThis(target);
})
})
The shuffle function :
function shuffleThis(target, thisType){
for ( var i = 0; i < 5; i++ ) {
if(i === 4){
setTimeout(function() {
var rand = randomizeIMG(thisType);
var finalRand = rand.split(/_(.+)?/)[0];
target.append( '<img src="assets/img/rds/'+ rand +'" />' );
target.children("img:first").fadeOut("slow").remove();
}, 75*i);
} else {
setTimeout(function() {
var rand = randomizeIMG(thisType);
target.append( '<img src="assets/img/rds/'+ rand +'" />' );
target.children("img:first").remove();
}, 75*i);
}
}}
It seems like iOS failed to repaint the DOM. Maybe a setTimout problem.
How to improve the result under iOS?