+ 3

How can I do this animation infinitive?

I mean, how can this box go left from right, when it is full max, to infinitive. Code: https://code.sololearn.com/WO5kU8e1v2Vw/#html

9th Mar 2019, 7:57 PM
Konrad Korpik
Konrad Korpik - avatar
2 Réponses
+ 3
Check if the box is > than the container width, if it is reset the position back to the start
10th Mar 2019, 12:19 AM
Ole113
Ole113 - avatar
+ 2
UPDATE: I done this! @Ole113 How can I (command) overwrite in else if position I mean position of the box to 0 again from 1888? Here: window.onload = function() { var pos = 0; var box = document.getElementById('interactive'); var t = setInterval(move, 10); function move() { if(pos < 1888) { pos += 1; box.style.left = pos+'px'; } else if(pos === 1888) { pos -= 1888; } else { ? } } }
10th Mar 2019, 8:39 PM
Konrad Korpik
Konrad Korpik - avatar