+ 5

Somebody can help me with my code ANIMATION? I need make the block go around inside your container.

I need help with my code

4th Jan 2017, 4:03 PM
ManuCarv
2 Réponses
+ 8
var left = 0, t, tp = 0; window.onload = function(){t = setInterval(lr,5);var box = document.getElementById("box");}; function lr(){ if (left < 150){ box.style.left = ++left + "px";}else{clearInterval(t);t = setInterval(tb,5);} } function tb(){ if (tp < 150){ box.style.top = ++tp + "px";}else{clearInterval(t);t = setInterval(rl,5);} } function rl(){ if (left > 0){ box.style.left = --left + "px";}else{clearInterval(t);t = setInterval(bt,5);} } function bt(){ if (tp > 0){ box.style.top = --tp + "px";}else{clearInterval(t);t = setInterval(lr,5);} }
4th Jan 2017, 4:42 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 6
thanks @ValentinHacker!
4th Jan 2017, 7:17 PM
ManuCarv