Oke, so i have a array of 6 objects (img.wolk) and i want them to move left to right randombly, at a random speed done that
But i also want that when they are out of the screen that they move to the other site and start over again, indefinitely.
So that when the object is all the way to the left that it teleports to the right and continues going left.
code
function wolkMovement() {
console.log(wolkMovement);
var wolken = document.querySelectorAll('img.wolk');
var speed;
var randomOrder = ['-50%', '100%'];
for (var i = 0; i < wolken.length; i++) {
var derection;
derection= randomOrder[Math.floor(Math.random() * randomOrder.length)];
speed= Math.floor(Math.random() * (100000 - 2000 + 1) + 2000);
//random the derection and the speed
$(wolken[i]).animate({
left: derection
}, speed, function () {
//teleport to other site and repeat
});
}
}