+ 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
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);}
}
+ 6
thanks @ValentinHacker!